Question : Access VBA - Need to wait a few seconds...

Im running a section of code in a modle and if my program encounters an error accessing a peice of data, I have it change a status lable to read "Data Access Failed Waiting 5 seconds before trying again..."

I've go this all set so that it will only retry 3 times before giving up attempting to auto access the data.

Whats the best way to setup a timer to wait for 5 seconds before continuing?

Cheers

Answer : Access VBA - Need to wait a few seconds...

Hi Andy1,

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

In the declarations section then:

Sleep 5000

Where you need to wait. This causes the thread to sleep for a period of time. This may be a better solution as a tight loop could increase processor usage and not allow your other applications to run.

If you use the tight loop approach, ensure that you also use DoEvents to release the processor inside the loop.

Tim Cottee
Random Solutions  
 
programming4us programming4us