Use the Replace function to double up the ' characters. Two ' characters in
a row is interpreted as a single ' character in a text string.
rs.FindFirst "[Applicant] = '" & Replace(Me![cboSelectApplicant2], "'",
"''", 1, -1, vbText) & "'"
Thanks for the code, Ken. (Wow, only 5 minutes after I posted the
question).
However, I'm getting a Compile Error on the "vbText" argument. It says
"Variable not defined."
I'm using Access 2002. Any ideas?
Paul
> Use the Replace function to double up the ' characters. Two ' characters
> in a row is interpreted as a single ' character in a text string.
[quoted text clipped - 22 lines]
>>
>> Paul
Paul Ponzelli - 10 Mar 2006 04:40 GMT
Well, one way to solve the problem is to use an Autonumber field as the
bound column for the combo box, and then I don't have to handle apostrophes
in the text string.
Thanks for your suggestion in any event, Ken.
> Thanks for the code, Ken. (Wow, only 5 minutes after I posted the
> question).
[quoted text clipped - 32 lines]
>>>
>>> Paul
Ken Snell (MVP) - 10 Mar 2006 14:40 GMT
Sorry... memory lapse... Use vbTextCompare (it's value is 1).

Signature
Ken Snell
<MS ACCESS MVP>
> Thanks for the code, Ken. (Wow, only 5 minutes after I posted the
> question).
[quoted text clipped - 32 lines]
>>>
>>> Paul
Paul Ponzelli - 11 Mar 2006 13:58 GMT
Ah! That did the trick.
Thanks.
Looking at the expression now, I have a question about it. I would have
thought that you need to put the Replace() function on both sides of the
equality for it to work. You have pointed out that two ' characters in a
row is interpreted as a single ' character in a text string, but I would
have thought that would apply to both sides of the equal sign. Why is it
only necessary to use it on the one side
Ken Snell (MVP) - 20 Mar 2006 19:06 GMT
Are you asking why you don't need to use the Replace function with the
Applicant field name on the left side of the equality? That is because it is
just the name of the field that contains the values that are to be searched,
so there is no need for any modification of its contents/values. Also, VBA
will not allow you to put functions, etc. on the left side of an equality,
as the syntax is that you're setting the value of the left side to the
result of some expression on the right side.

Signature
Ken Snell
<MS ACCESS MVP>
> Ah! That did the trick.
>
[quoted text clipped - 6 lines]
> have thought that would apply to both sides of the equal sign. Why is it
> only necessary to use it on the one side