Access - Sleep function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how can I make an access function 'sleep' for a short period. I want to
check the results of a query, process them, then wait for a short period
(e.g. 20 seconds) before checking the query results again. I've looked at
using the windows 'sleep' command but access issues the shell command
asychronously so that won't work. Has anyone else had a similar problem?
 
I know what you mean. the Sleep command is for VB scripting. In norder to
get VBA code to 'hang about for a bit', I use the following code:

Sub apWait(ByVal SecondsToWait As Single)
' Waits n seconds (or fraction)

Dim sngStart As Single


DoCmd.Hourglass True 'Change cursor


sngStart = Timer ' Set start time.
Do While Timer < sngStart + SecondsToWait
DoEvents ' Yield to other processes.
Loop


DoCmd.Hourglass False

End Sub

Hope this helps
 
There's code to do this at the following URL ...

http://www.mvps.org/access/api/api0021.htm

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
For the Sleep command to work while using Shell, the loop that does the
checking will need to be in VBA, calling Shell each time you loop. If you
place the loop in a batch file (or whatever you're calling from Shell) then
you will need to put the pause there instead. If it is a batch file that
you're calling, there are some Dos utilities that will do what you ask. They
are tiny and can probably be found as a free download. They work similar to
Sleep. One I have used is called Wait.com. To use it the syntax is simply
(wait 1000).
 
Back
Top