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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Error 1

Status
Not open for further replies.

istone

IS-IT--Management
Jan 24, 2007
139
US
Hi,
I created a combo box to filter client name. The combo box is working fine except on this case:
when I filter one of these name:
David's Financial or Rao's Specialty
I get this error:

Private Sub Combo170_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Client Name] = '" & Me![Combo170] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

I believe the error comes up because the names have an Apostrophe (').

Anyone have any idea
Thank you in advance
 
Hi!

You can use the following:

Const DblQuote = """"
rs.FindFirst "[Client Name] = " & DblQuote & Me![Combo170] & DblQuote

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Replace the single quotes with double so line reads:

rs.FindFirst "[Client Name] = "" & Me![Combo170] & """
 
A safer way:
Code:
rs.FindFirst "[Client Name] = '" & Replace(Me![Combo170], "'", "''") & "'"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top