Apostrophes in Form

luism

Registered User.
Local time
Today, 14:47
Joined
Sep 30, 2012
Messages
43
I have the following VBA code in a form

'Check for duplicates based on LName and warn
Private Sub LName_BeforeUpdate(Cancel As Integer)

'Find any matching records based on FName & LName
If DCount("*", "Tbl_Contacts", "[FName] & [LName] = '" & Me.[FName] & Me.[LName] & "'") > 0 Then

'If DCount > 0 then a matching record was found & display a Yes/No message box.
If MsgBox("Warning: Possible Duplicate! Continue?", vbYesNo, "Possible Duplicate!") = vbNo Then

'If the user clicked No, cancel the update & undo whatever was typed
Cancel = True
Me.Undo
End If
End If
End Sub

When I try to enter a new LName that contains an apostrophe the Form stands still and doesn't let me move on unless I change the apostrophe to another symbol. How can I tell my form to allow apostrophes?

Thanks!
 
Code:
If DCount("*", "Tbl_Contacts", "[FName] & [LName]  = " & Chr(34) & Me.[FName] & Me.[LName] & Chr(34)) > 0 Then
 
worked like a charm, thanks!
 

Users who are viewing this thread

Back
Top Bottom