OnTimer Performing an Action on an Interval

The On Timer property is an event that executes at a time specified by the Form's TimerInterval property. This is not a time like 5:34 p.m.; it is entered in milliseconds, which is 1/1000 of a second. So, if you want the On Timer property to execute every 3 seconds, then you would set the TimerInterval to 3000.

One practical use of the On Timer event property is to trigger code to notify users that they are to exit the application, perhaps for maintenance or an update. It is not uncommon to open a form, keep it hidden, and then execute On Timer to check a flag set by the administrator.

Private Sub Form_Timer()

If DLookup("Kickout", "ztblAppInfo") = True Then MsgBox "The application must be closed", _


"Administrative Request"


'Custom Procedure to exit application

End If

End Sub

The above example assumes that there is a table called ztblAppInfo, which has a Boolean field called Kickout. Using the DLookup function, the code will examine the Kickout field, and if it is true, it will display the message and exit the application.

0 0

Post a comment