Question : On timer event passes it's own time

Dear Experts,

I have a question regarding the OnTimer function of Ms Access.
I am wondering what happens when a timer event passes it's own time.
With this i mean the following.

-OnTimer event runs every minute
-Timer event costs 1.5 minute to complete

What will happen now? Will the timer event still run every minute or will the timer event run every 2 minutes?
If it tends to run every minute, will it 'remember' the times missed and queue them up somehow?

Thanks in adavance.

Regards, Johan

Answer : On timer event passes it's own time

It will run every minute.  Since the subroutine does not have enough time to complete and return control to the calling routine (the calling routine will be the timer event), the stack will fill up until you get a stack overflow. When you get a stack overflow, you may get a stack overflow error message, Access or Windows may lock up or you may get unpredictable events. For this reason, a timer event should always first set the timer interval to zero to turn off the timer, handle the event, then, if needed, turn the timer back on (see the example below) unless you absolutely KNOW the timer event code will ALWAYS run faster than the timer interval and you are using the timer interval to do real world timing (best to avoid this scenario).

Example:
Private Sub Form_Timer ()
TimerInterval = 0
Do stuff Here...
TimerInterval = 500
End sub
Random Solutions  
 
programming4us programming4us