making VBA wait

Mcgrco

Registered User.
Local time
Today, 21:07
Joined
Jun 19, 2001
Messages
118
I have a simple loop code which stops once a value is true. when this happens I wasnt the procedure to wait an hour before resuming.Does anyone know how to do this.

thanks
 
Having never tried anything like this, I can only offer suggestions of things to try. I hope these will be of some help.

1. I do not think you will be able to (or should even try to) pause the code execution. You should either re-start the loop from the beginning or use a global variable to store some type of id that will enable you to begin the loop at the place where you left off.

2. When you find the value that you want to 'pause' the code execution you could exit the loop and call a custom function that has a timer. I think that you will not be able to have a single timer run for an entire hour. You will probably have to put the timer in a loop or use a succesion of timers. Once the timers have reached an hour, then the custom function would call the original function.

3. If the user is likely to have moved a different form than the one that triggered the timer function, then that function should be in a module so that it can open the original form (I think).

Check the help menu for information on Timers and I think you will be able to achieve this...
HTH
Chris
 
When the True condition is met, have it set the timer interval value to 60,000 (one minute).
Have the timer event increment a global variable by '1' (starting at 0) every time it executes (adds one to itself every minute).
Have an If statement at the end of the timer event check to see if your global variable is equal to 60, if it is, set the timer interval and the variable to 0, and call the next procedure, or whatever is to happen next.

Darrin@CB69

[This message has been edited by cargobay 69 (edited 10-29-2001).]
 
Following on from Chris McBride's suggestion, try using the Application.OnTime function. This will enable you to schedule the exact time you want the code to start running. It also avoids using timers and hence having any code running during the hour pause.

HTH
wink.gif


[This message has been edited by PearlGI (edited 10-31-2001).]
 
PearlGI,

I haven't been able to locate the OnTime event for Application. Can you please provide more information
smile.gif


SteveA
 
Many, many apologies!!

It's actually an Excel function, not an Access one. Forgot I had the Excel references in my Access setup!!

It is a real shame Microsoft didn't feel the need to incorporate this function in Access as well. It's extremely useful.

Once again, apologies for getting your hopes up.
frown.gif
 

Users who are viewing this thread

Back
Top Bottom