<%dim crumb crumb="Timer Event" crumb1="VBA Timer Event in Access" %> Timer Event
Home   Fees/Services   Access Templates   Tutorials  Tutorial Downloads   Articles   Search   Contact  Privacy  Links
<% response.write crumb2 %>
<% response.write crumb1 %>
 Home > Microsoft Access Tutorial > Form Event Tutorials <% response.write "> " & crumb %>

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

Table-Level Events

Timer Event Example

Visual Basic Form Event Examples - Code Samples

VBA Timer event happens in a form 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

See how to use the timer event to logout users after idle time. Downloadable Timer Event Example

Form Triggers
Table Triggers
Form Flags
Table Triggers
Record Flags
Record Events

Microsoft Office:
MS Access 2003
Access 2007
Access 2010
Access 2013
Access 2016

Contact Information

<% Response.write "Copyright 2000-" & year(now) & " Blue Claw Database Design" %>