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

apostrophe in field name

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have a field that holds the company name. when the user enters in a company name the form searches for the company in the company table. My problem arises when a company contains an apostrophe.
rs.findfirst [com_name] = '" & companyname & "'...."
when the company name has an apostrophe it causes problems.
how do i resolve this???
 
Replace all instances single quotes with opening and closing double-quotes:

rs.findfirst [com_name] = """ & companyname & """ .... "

-Gary
 
I always took the brute force & ignorance approach & didn't allow apostrophes (in loaded data or user input). I'd check in a form or control's KeyPress event for Asc(39), set it to Null if it cropped up. I've seen various workarounds for the problem, but never found one that I was all-the-way comfortable with. Coward's way out, to be sure, but it's effective.
 
You may also consider this:
rs.findfirst "[com_name] = '" & Replace(companyname, "'", "''") & "'...."

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

Part and Inventory Search

Sponsor

Back
Top