By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,475 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,475 IT Pros & Developers. It's quick & easy.

buggy form filter control

P: 6
Hi all,

In my form, where, each individual record is a Subject with various data attached, I've set up a combo box to select which record I want to look at. The macro doing this is a SearchForRecord where:
Expand|Select|Wrap|Line Numbers
  1. , , First, ="[PathwayName] = " & "'" & [Screen].[ActiveControl] & "'"
This works fine most of the time. The problem comes when some of the subjects have apostrophes in their names; for example, "Crohn's disease". I understand that this is because this is the same character as the text delimiter, but that's where my debugging grinds to a halt, because I don't know how to go about making this *not* an issue.

Anyone got any advice for me? I'm using Access 2007, and prefer macros to VBA as I'm not an advanced programmer, so I wouldn't know where to start with sorting this out through the real code.

Thanks, and Merry Christmas,
Toireasa
Dec 23 '08 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 1,287
Instead of surrounding your string variables with the apostrophe you can use two double quotes like "". They will be evaluated to 1 double quote in the resulting string.

"[PathwayName] = "" " & [Screen].[ActiveControl] & " "" "
I spaced them out for clarity.

I would normally write
"[PathwayName] = """ & [Screen].[ActiveControl] & """"
Dec 23 '08 #2

P: 6
Thanks Chip - that works perfectly!
Dec 23 '08 #3

NeoPa
Expert Mod 15k+
P: 31,186
Check out Quotes (') and Double-Quotes (") - Where and When to use them.

I would suggest wrapping the reference up in a wrapper function that doubles any single-quotes found.
Dec 23 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.