?
Solved

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

Posted on 2009-04-08
3
Medium Priority
?
895 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 75 total points
ID: 24100800
disables it
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 150 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 150 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

752 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