The creation and customization of database applications using Microsoft Access
Hi. Couple of things: When checking for duplicates,
- I usually use the BeforeUpdate event, and
- I tend to use the DCount() function
So, for example, perhaps something similar to this:
Private Sub txtSealNumber_BeforeUpdate(Cancel As Integer)
Dim strCriteria As String
strCriteria = "TrailerNumber='" & Me.txtTrailerNumber & "' AND SealNumber='" & Me.SealNumber & "'"
If DCount("*", "Tab_TrailerDetails", strCriteria) > 0 Then
Cancel=True
Me.txtSealNumber.Undo
MsgBox "Please make sure...", vbInformation, "Duplicate!"
End If
End Sub
Hope that helps...