Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

Forcing Wait or Delay ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SheldonMopes@KidNet.com - 05 Feb 2006 03:54 GMT
Is there a way to force Access to pause execution for a specified
period of time ? I would like a command button on a form to run it's
code when clicked and then pause for 2 seconds before allowing any
other user input. Thank you for any help.
Wayne Gillespie - 05 Feb 2006 04:03 GMT
>Is there a way to force Access to pause execution for a specified
>period of time ? I would like a command button on a form to run it's
>code when clicked and then pause for 2 seconds before allowing any
>other user input. Thank you for any help.

Put the following into your code where you want the pause.

Dim T1 As Variant
Dim T2 As Variant

T1 = Now()
T2 = DateAdd("s", 2, T1)

Do Until T2 <= T1
   T1 = Now()
Loop

Wayne Gillespie
Gosford NSW Australia
teddysnips@hotmail.com - 06 Feb 2006 15:49 GMT
> >Is there a way to force Access to pause execution for a specified
> >period of time ? I would like a command button on a form to run it's
[quoted text clipped - 12 lines]
>     T1 = Now()
> Loop

If you're going to wait for an appreciable length of time, you might
want to put a DoEvents in the loop.

Edward
mike noel - 05 Feb 2006 04:09 GMT
You could use windows api stuff...

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

...

Sleep 2000

> Is there a way to force Access to pause execution for a specified
> period of time ? I would like a command button on a form to run it's
> code when clicked and then pause for 2 seconds before allowing any
> other user input. Thank you for any help.
Jeremy Wallace - 06 Feb 2006 18:04 GMT
I use Trevor Best's code:
Sub WaitFor(psngSeconds As Single)
' wait for specified number of seconds
' Copyright Trevor Best (tre...@besty.org.uk) <-OK, so I added
thisline.

Dim sngStart As Single
Dim sngET As Single

sngStart = Timer
DoEvents
Do While sngET < psngSeconds
   DoEvents
   ' check for mighnight as the Timer() function will
   ' rollover at this point
   sngET = Timer - sngStart
   If sngET < 0 Then
       ' it rolled over - add number of seconds
       ' in a day
       sngET = sngET + 86400
       Beep
   End If
   ' now don't hog the processor
   ' release some CPU slices back to Windoze
   DoEvents
Loop

End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.