Home  Fees/Services  Access Templates  Tutorials  Tutorial Downloads  Articles  Search  Contact  Privacy  Links
VBA Timer Event in Access

Form Event Tutorial
VBA Timer Event in Access

Access Event Tutorials:
Before Insert Event
After Insert Event
After Update Event
Before Update Event
Change Event
Close Event
Current Event
Double Click Event
Error Event
Exit Event
VBA Timer Event
Undo Event

Timer Event Example

Visual Basic Form Event Examples - Code Samples

VBA Timer event happens in a from based on the setting (in milliseconds) of the Timer Interval form property.  You can use the timer event to create stop watch functions within Access databases.

Visual Basic Timer Event Example:

In the Timer Event example we cause a time of day text field to be updated every 10 seconds.

First we set the Timer Interval of the database form to be 10000 milliseconds, then:

Private Sub Form_Timer()
  Me!Time_of_Day= Time
End Sub

Now for a more useful example of the Timer and On Timer event.  If you want MS Access to perform some operation at a regular interval then you can use the timer interval and timer event in combination to run some action.

In the example below we establish a time interval for the form of 10000 milliseconds (10 seconds).

Then the timer event procedure contains code to re-query the form.  So the form gets re-queried every 10 seconds.  You could have the database perform most any action.. Such as running a report,  Sending/receiving emails, popup meeting reminders, etc.

The only problem with this method is that the database has to be up and running for the repetitive action to occur.

If you don't want to have the database running continuously then you can use Windows task scheduler to run the database at regular intervals.  In that case there is no need to have the event timer code.

Private Sub Form_Open(Cancel As Integer)
Me.TimerInterval = 10000
End Sub

Private Sub Form_Timer()
MsgBox "requery"
End Sub

A Blue Claw Database Design Template:

Farmer's Feed Inventory Tracking Database

A Blue Claw Database Design Article:

MS Access Versus Other Systems

Contact Information

Copyright 2000-2015 Blue Claw Database Design