I have a dropdown box that has a text field as the control source.
LimitToList set to No.
When I try to enter any string containing an apostrophe (like Hopper's)
I get the following error message:
"Syntax error (missing operator) in query expression: '[to] = 'Hopper's".
Is there a way to allow the apostrophe (') character in this string?
The problem is in the toCombo_AfterUpdate procedure.
Here is the code:
Result = DLookup("[to]", "toTbl", "[to]='" & Me![toCombo] & "'")
If IsNull(Result) Then
' Ask the user if he or she wishes to add the new value.
Msg = Me![toCombo] & " is not in the list." & CR & CR
Msg = Msg & "Do you want to add the new value?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
' If the user chose Yes, add the new value to the table.
DoCmd.OpenForm "setupToFrm", acNormal, , , , acWindowNormal
DoCmd.GoToRecord acDataForm, "setupToFrm", acNewRec
Forms![setupToFrm]![to] = Me![toCombo]
The problem is with the following line: