Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • 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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

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