N
Nerida Menzies via AccessMonster.com
I am trying to compare a employee code that is entered into a form with a
list of existing employee codes to make sure employees are not entered twice.
Using the On Exit event I am using a bit of code I found in Access’ help:
Private Sub ServiceNo_Exit(Cancel As Integer)
If (Not IsNull(DLookup("[ServiceNo]", "tblParticipantDetails", _
"[ServiceNo]='" & Me!ServiceNo & "'"))) Then
MsgBox ("ServiceNo has already been entered in the database.")
Cancel = True
Me!ServiceNo.Undo
End If
End Sub
I keep getting a “Run time error 62506 – Data Type Mismatch in criteria
expression. I know the problem likes in the last part of the DLOOKUP, maybe
something to do with the single and double quotes, but I just can’t seem to
crack it. I have spent hours trying to work out what the problem is. If
anyone can help I’d most appreciative.
Cheers,
Nerida.
list of existing employee codes to make sure employees are not entered twice.
Using the On Exit event I am using a bit of code I found in Access’ help:
Private Sub ServiceNo_Exit(Cancel As Integer)
If (Not IsNull(DLookup("[ServiceNo]", "tblParticipantDetails", _
"[ServiceNo]='" & Me!ServiceNo & "'"))) Then
MsgBox ("ServiceNo has already been entered in the database.")
Cancel = True
Me!ServiceNo.Undo
End If
End Sub
I keep getting a “Run time error 62506 – Data Type Mismatch in criteria
expression. I know the problem likes in the last part of the DLOOKUP, maybe
something to do with the single and double quotes, but I just can’t seem to
crack it. I have spent hours trying to work out what the problem is. If
anyone can help I’d most appreciative.
Cheers,
Nerida.