Pause code

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
 
C

Clifford Bass

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
 
S

Stephen sjw_ost

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
 

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