Sleep() and Form_Timer() conflict

H

H. Martins

Hi.

I am using this function to make Access wait a bit:

Private Declare Sub Sleep Lib "kernel32" (ByVal millisecs As Long)
....
Sleep (1000)

The problem is that in the same form, Form_Timer() is running and once
Sleep() starts, the timer stops running (copying some variables to
some text boxes, once, every 125 miliseconds).

Can I have some help, please?

Thanks
H. Martins
 
R

ruralguy via AccessMonster.com

Try the following function instead of Sleep:

Public Function Pause(NumberOfSeconds As Variant)
'-- For use where you want to pause but still let
'-- Access have some computer time.
'-- From ghudson on Access World Forums
'-- http://www.access-programmers.co.uk/forums/showthread.php?t=94302
On Error GoTo Err_Pause
'-- Called with - Pause (.5) for a half second pause
Dim PauseTime As Variant, Start As Variant

PauseTime = NumberOfSeconds
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop

Exit_Pause:
Exit Function

Err_Pause:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Pause

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top