Timer Event Code Samples

March 11th 2003. Created with WordPad.
home

"Browse Data" Example

In this example, I wanted the database (my PO Invoicing Database from late 2002-2003) to prompt the user every 10 minutes with the option to update the "browse data," as they might not be of the tendency to do this themselves periodically (which did exist as an option via the customized pulldown menu "View...Refresh Browse Data.")

I created the following code which was placed in a form that was open in Hidden Mode


Private Sub Form_Timer()
' Code to prompt user every 10 minutes for updating the temp tables/browse data
Static nOneSecondCnt As Integer
' Timer Interval = 1000, makes every unit 1 second
nOneSecondCnt = nOneSecondCnt + 1
    If nOneSecondCnt = 600 Then  ' 10 minutes passed
        ' Code to execute at scheduled time interval goes here
        nOneSecondCnt = 0
        Dim response As Integer, message As String
        message = "Would you like to refresh the browse data"
        response = MsgBox(message, vbYesNo, "Refresh Data?")
        If response = vbYes Then
        ' Code to execute if user clicks Yes
        End If
    End If
End Sub

Also, as the comments in the above code mentioned, with this form open and its properties selected, I set the Timer Interval property to 1000.

Also, the code which opened the hidden form in hidden mode in the first place:

DoCmd.OpenForm "frmHiddenBootupForm", acNormal, "", "", , acHidden