Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apostrophe problem in query

Status
Not open for further replies.

kwor

MIS
Dec 10, 2008
35
AU
I have a form that displays contacts. Name, address, etc. On the form is a combo box that is used to find a contact. The following code is used on the after update event on the combo box:

Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Surname] = '" & Me![Find_Surname] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

This works perfectly except for names like O'Brien. What do I need to do to make the query work with apostrophes?
 
Code:
rs.FindFirst "Surname='" & Replace(Me![Find_Surname], "'", "''") & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It works.
Thank you - now I will work out the logic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top