Solved

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

Posted on 2009-04-08
3
887 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 25 total points
ID: 24100800
disables it
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 50 total points
ID: 24103348
(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
ID: 24111128
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

724 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