This Was Working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have just added a new record with ShowName = Int'l Lingerie Show
After my save this shows up in my combo but when I select this entry I get an
Syntax error (missing operator) in expression


rs.FindFirst "[ShowName] = '" & Me![Combo43] & "'"

This syntax works on every other show I have in my drop down list except the
one I just entered. I have deleted the record and re-entered the data and
still get the same error.

Any ideas what may be causing this???

Thanks in advance for any direction you may be able to give.
 
cvegas said:
I have just added a new record with ShowName = Int'l Lingerie Show
After my save this shows up in my combo but when I select this entry
I get an Syntax error (missing operator) in expression


rs.FindFirst "[ShowName] = '" & Me![Combo43] & "'"

This syntax works on every other show I have in my drop down list
except the one I just entered. I have deleted the record and
re-entered the data and still get the same error.

Any ideas what may be causing this???

Thanks in advance for any direction you may be able to give.

It's a common problem. The criterion expression you are passing to
FindFirst:
rs.FindFirst "[ShowName] = '" & Me![Combo43] & "'"

is using the single-quote character to quote the value of the combo box,
but the value of the combo box for this show includes that same
single-quote character, so the quoting of the text value is thrown off.
After substituting the value and evaluating the expression, you end up
with this:

[ShowName] = 'Int'l Lingerie Show'

It *looks* -- to the interpreter -- like the show name is "Int", but
then there's this other stuff stuck on the end that doesn't make sense.

To work around this you can use the double-quote character inside the
criterion instead. It's a bit tricky tio set up, but you can do it like
this:

rs.FindFirst "[ShowName] = " & _
Chr(34) & Me![Combo43] & Chr(34)

That will work so long as you never have a show name that contains the
double-quote character ("). If you think you may have such a show, then
you have to "double-up" the quotes within the show name, like this:

rs.FindFirst "[ShowName] = " & _
Chr(34) & _
Replace(Me![Combo43], Chr(34), Chr(34) & Chr(34)) & _
Chr(34)

Ugly, isn't it?
 
The problem is the apostrophe ' in the text gets mixed up with the
single-quotes you use to delimit the Text String.

For names, I generally use double-quotes to delimit String like:

rs.FindFirst "[ShowName] = """ & Me![Combo43] & """"

(that 3 double-quotes after the equal sign and 4 double-quotes at the end.)
 
Back
Top