|
||||||
Access Tip Sleep Timer By Richard Rost 4 years ago Want to add a delay in your Access VBA code? This is sometimes handy if you want to give the user time to react, or slow down processing so you can see what's going on, or even wait for a background process to finish. First, declare the following at the top of your module:
This is a Windows API function that you can use to pause a particular number of milliseconds. So:
would have processing sit there for a full second not doing anything. This function by itself locks up the whole computer and doesn't allow any input for that second, which is fine if it's only a second, but if you want, say, a 15 second pause, you're locking up the computer for a whole 15 seconds. So I created this function to go with it:
What this does is break up the timer into quarter second chunks (250 milliseconds) and the DoEvents code allows processing to continue if something else is happening in the background. It also allows you to put an ABORT button or checkbox on your form to give the user a chance to cancel it. Now you can say:
If anyone would like to see me make a video lesson about this, let me know.
|
||||||||||||||
| |||
Keywords: access tips sleepsec sleep timer delay PermaLink Access Tip Sleep Timer |