• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 552
  • Last Modified:

using apostrophe in drop down combo box

I have a form that has a combo box to filter records. The drop down is easy:
SELECT DISTINCT tblRateAgreements.[Firm Name]
FROM tblRateAgreements;

The user just starts typing the name, or scrolls down to the name they are looking for. However, when I have a name that contains an apostrophe, like Cozen O'Connor, I get the following error message. Is there a way to accommodate for apostrophe's?

Run-time error '3075':
Syntax error (missing operaot) in query expression '[FirmName]='Cozen O'Connor".
0
4charity
Asked:
4charity
  • 3
  • 3
1 Solution
 
Rey Obrero (Capricorn1)Commented:
yes,
others will suggest to use Replace(str,"'","''")
but you can just use

"[firmName]=" & chr(34) & me.comboName & chr(34)
0
 
4charityAuthor Commented:
capricorn,
Where am I putting this? All I have is this in my SQL Statement: Query Builder

SELECT DISTINCT tblRateAgreements.[Firm Name]
FROM tblRateAgreements;
0
 
Rey Obrero (Capricorn1)Commented:
where did you get this error
'[FirmName]='Cozen O'Connor". ?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
4charityAuthor Commented:
When I choose that name (Cozen O'Connor) as a Firm Name from the combo box.
0
 
Rey Obrero (Capricorn1)Commented:
post the codes in the afterupdate event or change event whichever is used, of the combo box..
0
 
4charityAuthor Commented:
That was it! I made the change in the After Update event. I was looking in the wrong place. Thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now