escape character

N

Nathan

Okay, this seemed like it would be simple but I'm having a
heck of time with it. I'm just trying to filter a query
based on a users selection in a combo box. If the combo
box is empty, I want no filter to apply. I've first tried:

IIf(IsNull([Forms]![WarrantyClaims]![category]),Like "*",
[Forms]![WarrantyClaims]![category])

in the appropriate Criteria field in design view.
However, I think the Like "*" phrase needs to have quotes
around it ("Like "*"") but then Access says "the
expression is typed incorrectly or is too complex to be
evaluated". My thought was that the quotes inside the
quotes need to be escaped but I can't figure out what the
escape character is (I tried \" , ["] , and even '' ).

I'm probably doing something stupid.
 
C

Cameron Sutherland

You can do it two different ways.
1. Change your query criteria to:
Like "*" & [forms]![form1]![text1] & "*"
this way if they leave it blank you still get all. The
downside is if they enter 'cam' it returns all enteries
with cam inside not just the ones matching 'cam'

2. Have a hidden text box that has a control source that
points to the real text box but change the control source
so it displays a * if null then point your query to the
hidden text box instead.
Hidden text box control source:
=IIf(IsNull([text1]),"*",[text1])

-Cameron Sutherland
 

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