I have a textbox on a form that when you lose focus it checks for duplicate. Works fine EXCEPT: If I type a word with an apostrophe I get a syntax error. "tonys" will work, "tony's" will give me the error. Here is the code.
Criteria = "[Prodres] = '" & Me.[txtprodres] & "'"
If Not IsNull(DLookup("[Prodres]", "tblMain", Criteria)) Then
DoCmd.RunSQL " INSERT INTO tblProdDup(DupRec) VALUES (txtprodres);"
MsgBox " Similar existing record. Please check for duplication
Criteria = "[Prodres] = '" & Me.[txtprodres] & "'"
If Not IsNull(DLookup("[Prodres]", "tblMain", Criteria)) Then
DoCmd.RunSQL " INSERT INTO tblProdDup(DupRec) VALUES (txtprodres);"
MsgBox " Similar existing record. Please check for duplication