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

Recordset.Find names with apostrophes 1

Status
Not open for further replies.

Sypher2

Programmer
Oct 3, 2001
160
0
0
US
I can't seem to do a SQL query or a recordset.find if a name has an apostrophe. Example:

Code:
rs.Find "Name='" & lstFullName.List(i) & "'"

If the name selected in the listbox has an apostrophe (O'Connor, O'Donald, etc.) then I get an error since there are a total of 3 apostrophes in the Find statement. Is there any way around this? I've tried using brackets to no success. Thanks.
 
if there aren't any " then you can surround the name with chr$(34) (which is ").

Or you can replace the single quote with a '' before doing the find. Peter Meachem
peter@accuflight.com
 
Try this please

rs.Find "Name='"&Replace(lstFullName.List(i),"'","''") & "'"



This replaces all the single quate's in two single quotes

Good luck
 
Thanks! The Replace function worked perfectly. =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top