Solved

What happens when you set the timer event in MS/Access (VBA) to 0?

Posted on 2009-04-08
3
838 Views
Last Modified: 2013-11-27
I'd like to know if setting the VBA Timer event actually causes an internal event handler to do something.  Would there be any reason or benefit to setting the timer to 0?  Does anything happen, does it happen really really fast, or does nothing happen at all?
0
Comment
Question by:rdbrunet
3 Comments
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 25 total points
Comment Utility
disables it
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 50 total points
Comment Utility
(No points wanted)

If you have it set to a value in Code:
Say, 3000 (3 seconds), then evey 3 seconds the code runs.
As rockiroads states, setting it to zero in the code will disable it.

The same is true for settng it in the Form properties.
If you notice; the TimerInterval property of a form is set to Zero (0) by default (disabled)
;-)

So to clarify, setting the Timer Interval to zero does not trigger any event handler.
In fact, setting it to zero is the only way that I know of to disable it.
For example, if you wanted to turn off the timer, what else besides setting it to zero would you use?
;-)

JeffCoachman
0
 

Assisted Solution

by:EddieGee001
EddieGee001 earned 50 total points
Comment Utility
As rockiroads says, setting the interval to zero disables it.

I would add that this is the whole point. For example, on an Access form, you might want to have a control disappear once it has lost focus. You can't set the visible property to false in the lostfocus event because when the event triggers the control still has focus. Instead, when the control first is made visible, you move the focus to it and then set the timer interval to a short number, say 30. Then, you use this timer function:

Private Sub Form_Timer()
    If Me.ActiveControl.Name <> "theControl" Then
        Me.theControl.Visible = False
        Me.TimerInterval = 0
    End If
End Sub

As long as the control has focus, it will be the ActiveControl and nothing will happen, but the timer function will keep cycling through. As soon as another control has focus, The timer function will make the control invisible. It will then set the interval to 0 so the function will no longer be invoked.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now