[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

using apostrophe in drop down combo box

Posted on 2010-09-16
6
Medium Priority
?
544 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
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…
Suggested Courses

872 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