Need a quote in my expression

D

dbouton

I'm fairly new to Access but I have my results I need except for one
thing. I created my Table and queries. I know when I want words in my
results I put quotes around them when I build the expression. However
the output I need actually contains quotes. I tried to use two single
quotes to get the desired result but this did not work. Here is a
basic desired result:

dsmod group "CN=xxxxx" where xxxxx is a field in my table

So when I build my expression I need to have the set of quotes in
there. How do I do this? Hope I explained it well.

Dawn
 
M

Marshall Barton

I'm fairly new to Access but I have my results I need except for one
thing. I created my Table and queries. I know when I want words in my
results I put quotes around them when I build the expression. However
the output I need actually contains quotes. I tried to use two single
quotes to get the desired result but this did not work. Here is a
basic desired result:

dsmod group "CN=xxxxx" where xxxxx is a field in my table

So when I build my expression I need to have the set of quotes in
there. How do I do this? Hope I explained it well.


If the string contains the quote characters used to delimit
the beginning and end of the string, then the inner quotes
must be doubled. e.g.

xx = "O'Riley said ""Hello"" " {anywhere}
xx = 'O''Riley said "Hello" ' {not in VBA}

How you do this depends on how you use the string. If you
are just using the string literal in a statement as above,
then that's sufficient. If you are using the value of a
variable, control or field in a larger expression, then,
since you are not typing the string, you need to use the
Replace function to double them up. e.g.

s = s & "ff Like ""*" & Replace(xx, """", """""") & "*"""

which could end up with s containing something like:

SELECT * FROM table
WHERE ff Like "*O'Riley said ""Hello""*"

This really is a confusing subject so just keep struggling
with it until your mind gets a grip on it.
 
D

dbouton

The double quotes did it. Yes it is confusing and took several tries
but I finally got it using the right combination of double quotes in
the right spots. Thank you so much for your help.

Dawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top