Combo Box error

J

Jyoti

I have a combo box on the form which lists values from a
Table. When I select a data from the list, it displays the
record details based on a combo box selection. However if
there is data in the list with a 'Apostrophe'(Ex: Sam's)
I get an error.

Here is the code.

Dim Rs As Object
Set Rs = Me.Recordset.Clone
Rs.FindFirst "[CUSTOMER] = '" & Me![Combo1] & "'"
Me.Bookmark = Rs.Bookmark

Thanks in advance.

Jyoti
 
M

MacDermott

Try using this:

Rs.FindFirst "[CUSTOMER] = '" & Replace(Me![Combo1],"'","''") & "'"

HTH
 
G

Guest

Thanks.

-----Original Message-----
Try using this:

Rs.FindFirst "[CUSTOMER] = '" & Replace(Me! [Combo1],"'","''") & "'"

HTH

I have a combo box on the form which lists values from a
Table. When I select a data from the list, it displays the
record details based on a combo box selection. However if
there is data in the list with a 'Apostrophe'(Ex: Sam's)
I get an error.

Here is the code.

Dim Rs As Object
Set Rs = Me.Recordset.Clone
Rs.FindFirst "[CUSTOMER] = '" & Me![Combo1] & "'"
Me.Bookmark = Rs.Bookmark

Thanks in advance.

Jyoti


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top