Solved

using apostrophe in drop down combo box

Posted on 2010-09-16
6
478 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
  • 3
  • 3
6 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero 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 119

Expert Comment

by:Rey Obrero
ID: 33694207
where did you get this error
'[FirmName]='Cozen O'Connor". ?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

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

Expert Comment

by:Rey Obrero
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now