Syntax error (missing operator)

J

JohnLute

I have a form that displays a syntax error when I use the double-click
function of a coded combo box:

Syntax error (missing operator) in query expression
'txtProfileID="Pallet 48" X 40"".

The debugger points to this line of code:

DoCmd.OpenForm strFormToOpen, acNormal, _
WhereCondition:="txtProfileID=""" & .Value & """"

I think the problem lies with the use of " in the ID Pallet 48" X 40". If
this is the problem how can I resolve it? If it's not the problem then what
might it be and how can it be resolved?

THANKS for you help!
 
A

Allen Browne

You need to double up the quotes inside the string, i.e.:
"Pallet 48"" X 40"""

Try pasting the function below into a general module.
Save.

Then use like this:
WhereCondition = "txtProfile = "" & DoubleUpQuotes(.Value) & """"

Function DoubleUpQuotes(strIn As String) As String
DoubleUpQuotes = Replace(strIn, """", """""")
End Function
 
Top