In the After Update Event of the field Lastname I have some code to check
if a person with that First- and Last name already exists in the database:
If DCount("*", "[tblPeople]", "[LastName]= '" & Me.LastName & "' And [Firstname] = '" & Me.FirstName & "'") Then
Beep
MsgBox "This name already exists in the database!" & vbCrLf & " Please check for duplicate entry.", vbExclamation, ""
Me.Undo
Cancel = True
This works just fine, but the problem starts when the Lastname is something
like: O'Leary.
Then I get this error:
Syntax Error(Missing Opererator) in Query Expression '[Lastname] = 'O'Leary'
and [Firstname] = 'John".
Obviously it is the ' that is causing the problem.
Any solution for this?
Thank you all.
if a person with that First- and Last name already exists in the database:
If DCount("*", "[tblPeople]", "[LastName]= '" & Me.LastName & "' And [Firstname] = '" & Me.FirstName & "'") Then
Beep
MsgBox "This name already exists in the database!" & vbCrLf & " Please check for duplicate entry.", vbExclamation, ""
Me.Undo
Cancel = True
This works just fine, but the problem starts when the Lastname is something
like: O'Leary.
Then I get this error:
Syntax Error(Missing Opererator) in Query Expression '[Lastname] = 'O'Leary'
and [Firstname] = 'John".
Obviously it is the ' that is causing the problem.
Any solution for this?
Thank you all.
Last edited: