Special Character '#'


G

Guest

Is it possible to query a field for a special character '#'?
I'm trying to query a desc field that has '(B#)' in it.
So far, I'm using: Like "*(B#)*", but it's not working, i.e. not result
from query. It looks like it's the '#' symbol that's causing the trouble. I
also tried Like "*(B\#)*" but, also without success.
Any other way to query this? Thank you.
 
Ad

Advertisements

B

BruceM

LIKE "*" & "(B#)" & "*"

If '(B#)' is always at the end:

LIKE "*" & "(B#)"

Vice versa if it is always at the beginning.
 
G

Guest

Thanks for your response. But MsAccess is still treating the '#' as a special
character (lke the wildcard '*') for numericals only. I need to retrieve the
symbol '#', not the implication of #. Any other ways? Thanks.
 
G

Guest

I figured it out from one of the previous postings: Use brackets to enclose
the literal, i.e.: Like "*(B[#])*"

Thanks for all your help!
 
J

John W. Vinson

Is it possible to query a field for a special character '#'?
I'm trying to query a desc field that has '(B#)' in it.
So far, I'm using: Like "*(B#)*", but it's not working, i.e. not result
from query. It looks like it's the '#' symbol that's causing the trouble. I
also tried Like "*(B\#)*" but, also without success.
Any other way to query this? Thank you.
# is a wildcard meaning "any numeric digit".

To search for a literal wildcard character (e.g. #, *, ?), enclose it
in square brackets:

LIKE "*(B[#])*"


John W. Vinson [MVP]
 
Ad

Advertisements

J

John Nurick

Hi Samantha,

Try
LIKE "*(B[#])*"

# in a LIKE expression signifies a digit. [ ] define a character class
(e.g. [A-Z]) and [#] is a class consisting of the one character '#'.
 

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