Solved

using apostrophe in drop down combo box

Posted on 2010-09-16
6
474 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

708 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

12 Experts available now in Live!

Get 1:1 Help Now