How about some method that forces the form to filter when a new record
That's easily enough done, though I'm not sure I gather your idea. Anyway,
you could use the OnCurrent event and check for a new record, executing some
code or another based on what it finds.
Private Sub Form_Current()
If Me.NewRecord = True Then
'Set some sort of filter?
End If
End Sub
I think I see where you're coming from now... although I'm not sure if you
could set a filter without losing the 'NewRecord' status.
Unfortunatly access doesn't provide a 'BeforeCurrent' event (AFIAK).
But, if you were to keep a variable private to the form's module, and have
it hold the record number of the previous record... (more thinking out loud)
on the OnCurrent event (when the user navigates away), check for details
against the previous record (the one in the variable). If no records details
are found, force the user back to that record.
Something like this....
Option Compare Database
Option Explicit
Private pLastID As Long
Private Sub Form_Current()
'Check for Null in case we're just opening the form
If (Not IsNull(pLastID)) And (Me.NewRecord = False) Then
'Check for details from the last record
If FunctionThatChecksRecords = False
DoCmd.GotoRecord....
GoTo ExitSub
'I think you'll need the exit statement because
'if it changes records, this function will run once more
'for the new record, and then this one will finish
End If
End If
pLastID = Me.CurrentRecord
ExitSub:
Exit Sub
End Sub
Private Function FunctionThatChecksRecords() As Boolean
Dim strSQL As String
Dim rs As DAO.Recordset
...
...
End Function
That might actually do it. With a few touchups of course, but I think it
might be pretty close. Not too awfully bad of task.
--
Jack Leach
www.tristatemachine.com
- "First, get your information. Then, you can distort it at your leisure."
- Mark Twain