I have the following code that checks a recordset for duplicate records - Ihave not yet written the code to handle them - they will be allowed under certain circumstances.
All I need at the moment is for the new record to be undone if it is a duplicate. The code works fine if I comment out the filteron=false line but once I turn the filter off, the undo line stops working. The message still comes up so it is recognising it as a duplicate - I am confused as to why this is and more importantly how I can fix it.
Any help would be much appreciated.
Function isduplicate() As Boolean
Dim rst As Recordset
Application.Echo False
Forms!registerheader.RegisterQuery.Form.FilterOn = False
isduplicate = False
Set rst = Me.Recordset.Clone
rst.FindFirst "StudentID = " & Me!CboStudentID
If Not rst.NoMatch Then
Response = MsgBox("Record exists", vbYesNo)
Me.Undo
End If
rst.Close
Forms!registerheader.RegisterQuery.Form.FilterOn = True
Application.Echo True
End Function
All I need at the moment is for the new record to be undone if it is a duplicate. The code works fine if I comment out the filteron=false line but once I turn the filter off, the undo line stops working. The message still comes up so it is recognising it as a duplicate - I am confused as to why this is and more importantly how I can fix it.
Any help would be much appreciated.
Function isduplicate() As Boolean
Dim rst As Recordset
Application.Echo False
Forms!registerheader.RegisterQuery.Form.FilterOn = False
isduplicate = False
Set rst = Me.Recordset.Clone
rst.FindFirst "StudentID = " & Me!CboStudentID
If Not rst.NoMatch Then
Response = MsgBox("Record exists", vbYesNo)
Me.Undo
End If
rst.Close
Forms!registerheader.RegisterQuery.Form.FilterOn = True
Application.Echo True
End Function