Pause code

  • Thread starter Thread starter Stephen sjw_ost
  • Start date Start date
S

Stephen sjw_ost

How can I pause code for a specified amount of time without having the user
press any button(s) or click any "OK's"? I want to be able to control how
long the pause lasts. Is this possible?

Thanks for any help
Stephen
 
Hi Stephen,

You can use Allen's method or you can just use the Sleep function
available in one of the Windows DLLs. At the top of a plain module, before
any subroutines place this code:

Public Declare Sub Sleep Lib "Kernel32.dll" (ByVal lngMilliseconds As Long)

Then anywhere in code in any module, just use:

Sleep 10000

to pause for 10 seconds.

If it does not automatically change the cursor to a wait cursor, you
also may want to do so so as to indicate to the user that he/she should wait:

DoCmd.Hourglass True
Sleep 10000
DoCmd.Hourglass False

Clifford Bass
 
This is perfect. Thank you!

Clifford Bass said:
Hi Stephen,

You can use Allen's method or you can just use the Sleep function
available in one of the Windows DLLs. At the top of a plain module, before
any subroutines place this code:

Public Declare Sub Sleep Lib "Kernel32.dll" (ByVal lngMilliseconds As Long)

Then anywhere in code in any module, just use:

Sleep 10000

to pause for 10 seconds.

If it does not automatically change the cursor to a wait cursor, you
also may want to do so so as to indicate to the user that he/she should wait:

DoCmd.Hourglass True
Sleep 10000
DoCmd.Hourglass False

Clifford Bass
 
Back
Top