I'm trying to prevent creation of duplicate records in a time-recording database.
I get a "Run-time error 13 Type mismatch"
My code is:
Private Sub cboStaff_Exit(Cancel As Integer)
Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "StaffID = " & Me![cboStaff] & "" And "RecDate = " & Me![RecDate] & ""
If Me.RecordsetClone.NoMatch Then
Me!AddTime.SetFocus
Else
MsgBox "You Have Already Created an Entry for This Date.", vbOKOnly, "Duplicate Entry Found"
Me.Undo
End If
End Sub
StaffID is a number, RecDate is a Short Date
It seems to be the second criterion which is causing the problem.
Can anyone help me to identify my mistake?
I get a "Run-time error 13 Type mismatch"
My code is:
Private Sub cboStaff_Exit(Cancel As Integer)
Dim rsClone As DAO.Recordset
Set rsClone = Me.RecordsetClone
rsClone.FindFirst "StaffID = " & Me![cboStaff] & "" And "RecDate = " & Me![RecDate] & ""
If Me.RecordsetClone.NoMatch Then
Me!AddTime.SetFocus
Else
MsgBox "You Have Already Created an Entry for This Date.", vbOKOnly, "Duplicate Entry Found"
Me.Undo
End If
End Sub
StaffID is a number, RecDate is a Short Date
It seems to be the second criterion which is causing the problem.
Can anyone help me to identify my mistake?