One way to do this is to create a table that contains two date/time fields. The first date/time field would represent that a record was added or deleted from the "master" table. The send date/time field would indicate that a record, in the "master" table, was edited.
When your form opens, open the table and read in the 2 date/time fields and set them equal to public variables. In the OnTimer event of the form, check to see if either one of the date/time public variables are less than the ones in the table. If so, then either requery the form (if records were added/deleted) or refresh the form (if records were modified).
In the AfterInsert and AfterUpdate events of the form, you will need to update the table with the appropriate date/time values.
Example,
Table:
dtmRequery ... Date/Time field
dtmRefresh ... Date/Time Field
Form Module:
Dim mdtmRequery as Date
Dim mdtmRefresh as Date
Dim mrst as ADODB.Recordset
Sub Form_Open()
Open mrst and read 1st record
mdtmRequery = mrst!dtmRequery
mdtmRefresh = mrst!dtmRefresh
End Sub
Sub Form_Timer()
If (mdtmRequery < mrst!dtmRequery) And (Not Me.Dirty) Then
mdtmRequery = mrst!dtmRequery
Me.Requery
ElseIf (mdtmRefresh < mrstRI!dtmRefresh) And (Not Me.Dirty) Then
mdtmRefresh = mrstRI!dtmRefresh
Me.Refresh
End If
End Sub
Sub Form_AfterInsert()
mrst!dtmRequery = Now
mrst.UPDATE
mdtmRequery = mrstRI!dtmRequery
End Sub
Private Sub Form_AfterUpdate()
mrst!dtmRefresh = Now
mrst.UPDATE
End Sub