How to Code the Criteria?

B

bw

The Field for my SQL Statement Query Builder is E1: Left([Mnemonic],2)

When I have the Criteria as follows, it works fine:
Is Not Null And IIf([Forms]![boxStatusReport]![PrintOneOrAll]=3,"CL")

But if I want to check more values, like this:
Is Not Null And IIf([Forms]![boxStatusReport]![PrintOneOrAll]=3,"CL" or
"WX")

Access is changing my code to the following:
Is Not Null And
IIf([Forms]![boxStatusReport]![PrintOneOrAll]=3,(Left([mnemonic],2))="CL" Or
(Left([mnemonic],2))="WX")
and giving me the following error message when [PrintOneOrAll]=3:

"This expression is typed incorrectly, or it is too complex to be evaluated.
For example, a numeric expression may contain too many complicated elements.
Try simplifying the expression by assigning parts of the expression to
variables."

Can someone explain the proper way to do what I'm trying to do? By the way,
additional values on separate lines of the criteria as there will be more
values than the two that I have shown here.

Thanks,
Bernie
 
S

Steve Schapel

Bernie,

Try it like this... In a blank column of the query design grid, in the
Field row, put...
[Forms]![boxStatusReport]![PrintOneOrAll]
In the criteria row of this column, put 3 and in the same criteria row
of the E1 column, put...
"CL" Or "WX"
 
B

bw

Thank you, Steve!
That works fine, and is just what I wanted.
Bernie


Steve Schapel said:
Bernie,

Try it like this... In a blank column of the query design grid, in the
Field row, put...
[Forms]![boxStatusReport]![PrintOneOrAll]
In the criteria row of this column, put 3 and in the same criteria row
of the E1 column, put...
"CL" Or "WX"

--
Steve Schapel, Microsoft Access MVP
The Field for my SQL Statement Query Builder is E1: Left([Mnemonic],2)

When I have the Criteria as follows, it works fine:
Is Not Null And IIf([Forms]![boxStatusReport]![PrintOneOrAll]=3,"CL")

But if I want to check more values, like this:
Is Not Null And IIf([Forms]![boxStatusReport]![PrintOneOrAll]=3,"CL" or
"WX")

Access is changing my code to the following:
Is Not Null And
IIf([Forms]![boxStatusReport]![PrintOneOrAll]=3,(Left([mnemonic],2))="CL" Or
(Left([mnemonic],2))="WX")
and giving me the following error message when [PrintOneOrAll]=3:

"This expression is typed incorrectly, or it is too complex to be evaluated.
For example, a numeric expression may contain too many complicated elements.
Try simplifying the expression by assigning parts of the expression to
variables."

Can someone explain the proper way to do what I'm trying to do? By the way,
additional values on separate lines of the criteria as there will be more
values than the two that I have shown here.

Thanks,
Bernie
 

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