Home  Fees/Services  Access Examples  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links
Custom Database Design Consultants
 
Access Programming Examples
 
Access Example Downloads
Access Form Events Access Event Coding Examples
Form Event Programming
Access VBA Events

 Database Tutorials > Form Event Tutorials > Timer Event

                               

After Insert Event
After Update Event
Before Update Event
On Change Event
On Close Example
On Current Event
On DblClick Event
On Error Event
On Exit Event Help
VBA Timer Event
Undo Event Method


VBA Timer Event Example

Visual Basic Form Event Examples - Code Samples

Visual Basic/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.

Microsoft Access 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 TimerInterval 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 requery the form.  So the form gets requeried 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()
Me.Requery
MsgBox "requery"
End Sub

Contact Information

Event Procedures in MS Access
Microsoft Access 2003 2000 2002(XP) 97 All Windows Versions