Excluding multiple criteria in a field

F

fred w

I am trying to create a query that does not return values
of "Complete" and "Cancelled". If enter <> "Complete" the
query returns everything but "Complete" but if I try to
combine the two with an OR, I get all values in the field.

I appreciate the Help!

fred w
 
S

Stephen Epstein

You could use the logic:
Not In ("Complete","Cancelled")

That usually works for me.

HTH
SteveE
 
J

John Vinson

I am trying to create a query that does not return values
of "Complete" and "Cancelled". If enter <> "Complete" the
query returns everything but "Complete" but if I try to
combine the two with an OR, I get all values in the field.

That's because OR is a Boolean logical operator, not an English
language conjunction! Your expression makes sense in language but
computers are literal minded: if you say

[Field] <> "Complete" OR [Field] <> "Cancelled"

and the field does in fact contain the text string Cancelled, Access
will evaluate the first expression and say "ok, that's true,
'Cancelled' is not equal to 'Complete'"; then it will evaluate the
expression [Field] <> "Cancelled" and find that it is false.

The OR operator will then say "True OR False" - if either or both
expressions are True, return True.

So it will return TRUE and retrieve the record!

Use AND instead, or (more efficiently)

NOT IN("Complete", "Cancelled")
 

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