I am using Access VBA to create a recordset. The code works fine until I try to read in a field containing the name O’ Donnell. I get the above error (due to the apostrophe). My code to open the recordset is:
strStaff = “SELECT * FROM tblStaff” _
& ” WHERE [tblStaff]![stfForename] =” & Chr(39) & rsMailingList![First] & Chr(39) _
& ” AND [tblStaff]![stfSurname] = ” & Chr(39) & rsMailingList![Last] & Chr(39) & “;”
Set rsStaff = db.OpenRecordset(strStaff, dbOpenDynaset, dbOpenDynamic)
How do I get around the problem?