timerinterval

idxyz

Member
Local time
Today, 12:50
Joined
May 18, 2020
Messages
33
hi,
My corporate 64 bit office 365 running access, its Form TimerInterval causes stalls in the timer routine. Is there something new about the timer?. I see Logs do not get updated. inside the timer routine setting TimerInterval = abc causes routine inside the timer stop but not crash.
 
Can you be a bit more descriptive regarding "stalls" and how you recognize them?
 
when your timer event fires you need first to disable the timer, run the code and enable it again:
Code:
Private Sub Form_Timer()
    ' stop the timer from firing
    Me.TimerInterval = 0
    
    ' your code below
    '
    '
    
    ' re-enable the timer
    Me.TimerInterval = 1500

End Sub
 
Like at the line Me.TimerInterval = 0, it stops and does not proceed further.
I will check my code against the above suggestion.
 
Like at the line Me.TimerInterval = 0, it stops and does not proceed further.
I will check my code against the above suggestion.
 
Like at the line Me.TimerInterval = 0, it stops and does not proceed further.
I will check my code against the above suggestion.
What does a Timer Interval of 0 actually do? Is that a case of firing every 0 seconds--i.e. continually? Or is it a case of never firing at all? What does the documentation for Timer Interval in VBA tell us?
 
What does the documentation for Timer Interval in VBA tell us?

Oddly enough, the Microsoft Learn entry says nothing about the meaning of timerinterval = 0. Neither does the Microsoft Support article. However, I did find this note from our own archives:


Just to be ecumenical about it, I also found this article that includes mention of setting the form.timerinterval to 0.


However, if you look at the related Form_Timer event in Microsoft Learn, you get a reference to setting the interval to 0 as a way to turn off the timer.

 
Setting Me.TimerInterval to zero disables the timer. The Form_Timer() event handler will never execute while Me.TimerInterval = 0. In addition, if you set Me.TimerInterval to x, and then before x has expired you set it to x again, you effectively delay the execution of the OnTimer event handler.

If a search is slow, I sometimes use this in a 'search as you type' TextBox_Change event. The search is performed when the timer executes, but if the user enters another character quickly enough, the TextBox_Change event restarts the timer, and the search is delayed again. This way the search only executes after the user stops typing, which can dramatically improve the apparent performance of search as you type.
 
Like at the line Me.TimerInterval = 0, it stops and does not proceed further.
Can you post a demo of this? Does it break into the debugger? I have never seen VBA code just stop.
 
Think we need to see the code that sets the timer event and the timer event code

For all we know the timer interval is set in a button click event and the last line of the timer event code sets it back to zero - so no further code will run until another event fires- so is effectively stopped
 
Setting Me.TimerInterval to zero disables the timer. The Form_Timer() event handler will never execute while Me.TimerInterval = 0. In addition, if you set Me.TimerInterval to x, and then before x has expired you set it to x again, you effectively delay the execution of the OnTimer event handler.

If a search is slow, I sometimes use this in a 'search as you type' TextBox_Change event. The search is performed when the timer executes, but if the user enters another character quickly enough, the TextBox_Change event restarts the timer, and the search is delayed again. This way the search only executes after the user stops typing, which can dramatically improve the apparent performance of search as you type.
I was kind of hoping the OP might do the due diligence to learn and report what Me.TimerInterval = 0 does as a learning exercise. 😏
 
yes, Me.TimerInterval = 0 is to stop timer.
thanks to

arnelgp.​

Et al.
How to disable enable timer using a property handler?.
 
Like at the line Me.TimerInterval = 0, it stops and does not proceed further.

But the question is, what executable line of code FOLLOWS this action to set the timerinterval to 0?

Any code in the form's class module can theoretically start the timer by putting a non-zero value in the timerinterval slot for the form. Any code in the class module can put a zero in that slot to stop the timer. IF you stop the timer before the interval has been reached, the timer event will not fire but any code in the same routine following the zeroing out of the timer should continue to execute to the next EXIT SUB or END SUB.

If you continue to put an interval in the timer that is VERY small (like, less than a couple of seconds), you can have what appears to be a massive slowdown because of frequent timer events overloading the system, and it should be noted that events are NOT interrupts. They are scheduled events that get put into an event execution queue and executed in their due turn. It IS possible to use a really short timer interval and "lock up" the system. If the timer has something complex to do and the interval is reloaded early in the timer event code, it would be possible to have nearly continuous event firing. In which case you would get a "Not Responding" situation and would have to HOPE that you could use CTRL/Pause to take a break in the code so that you could use Windows Task Manager to shut down Access.
 
hi,
My corporate 64 bit office 365 running access, its Form TimerInterval causes stalls in the timer routine. Is there something new about the timer?. I see Logs do not get updated. inside the timer routine setting TimerInterval = abc causes routine inside the timer stop but not crash.
Stalling can occur because of several issues.
1) If what your timer event does takes longer than the timer interval, the timer can seem to be "Stuck" as it keeps getting called.
2) If what the timer does is some kind of loop or operation that can take a while, but you don't have a DoEvents() in your loop or structure, your timer even can seem to make the machine hang.
3) If your code calls code that does not internally allow other events to be handled, your timer can seem to stall.

I'd suggest posting your event_timer code so we can look to see if we can spot the problem.
I've seen this happen a long time ago when a loop structure didn't have a way to terminate, so the loop built up an array in memory to the point the poor HD was beaten badly.
 

Users who are viewing this thread

Back
Top Bottom