FindFirst Problems With Apostrophe '

Benjamin Bolduc

Registered User.
Local time
Today, 12:01
Joined
Jan 4, 2002
Messages
169
Hello there,

I have a combobox in a form used to bring up inventory information, by Item Description.

Several of the items have apostrophies in thier discriptions. When I use the combobox (using FindFirst), to pull these up, I get an error.

I've no doubt that the apostrophe is causing the problem, but I don't know how to bypass/fix it.

I searched though the forum, but only found one other post with the same problem. The answer, however, does not fit my situation.

Is there an easy way to modify the following code to allow apostrophies, while maintaining the functionality of the lookup combobox?

Set rs = Me.Recordset.Clone
rs.FindFirst "[Item Description] = '" & Me![ItemLookup] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Thanks so much for your help!
Ben Bolduc
 
The following line modification should solve your problem:
Code:
rs.FindFirst "[Item Description] = '" _
    & Replace(Me![ItemLookup], "'", "''") & "'"
 
Hey thanks alot! That worked like a charmed. Now I'll know how to avoid that problem in the future.
 
Here's another solution that does not involve changing the data:
Code:
rs.FindFirst "[Item Description] = " & Chr(34) & Me![ItemLookup] & Chr(34)
 

Users who are viewing this thread

Back
Top Bottom