Solved

using apostrophe in drop down combo box

Posted on 2010-09-16
6
518 Views
Last Modified: 2013-11-28
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
Comment
Question by:4charity
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 33693805
yes,
others will suggest to use Replace(str,"'","''")
but you can just use

"[firmName]=" & chr(34) & me.comboName & chr(34)
0
 

Author Comment

by:4charity
ID: 33694163
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
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 33694207
where did you get this error
'[FirmName]='Cozen O'Connor". ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:4charity
ID: 33694225
When I choose that name (Cozen O'Connor) as a Firm Name from the combo box.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 33694258
post the codes in the afterupdate event or change event whichever is used, of the combo box..
0
 

Author Closing Comment

by:4charity
ID: 33694325
That was it! I made the change in the After Update event. I was looking in the wrong place. Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question