Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excluding non-consecutive items?

Status
Not open for further replies.

morg59jeep

Technical User
Jun 21, 2006
23
I have a record that excludes one record using this code

<>"4097"

I now need to exclude a few more records as well. I tried to use

<>"4097" And "5002" And "5474"

This did not work. It only excluded the 4097 .. so what do I use to exclude more than one non-consecutive record.
 
Not In ("4097","5002","5474")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PH's way is the best. Before I learned how to use In() methods, I did it like this:

<> "4097" OR <> "5002" OR <> "5474"

That should further explain what In() is doing.

~Melagan
______
"It's never too late to become what you might have been.
 
I think the alternative to NOT IN ('4097', '5002', '5474') would be

<> "4097" AND <> "5002" AND <> "5474"

because any value of the field will be NOT EQUAL to at least two of those values so the OR operator will return every record.
 
Neither of those actually work. Both

<> "4097" OR <> "5002" OR <> "5474"

and

<> "4097" AND <> "5002" AND <> "5474"

result in all records showing with only the 4097 removed. They work great for one value but with multiple values they only filter out the first one.
 
I was assuming that you were using query design rather than SQL view. If you were then the "Criteria" line for the field would contain

<> "4097" AND <> "5002" AND <> "5474"

In SQL view however you would need

myField <> "4097" AND myField <> "5002" AND myField <> "5474"
 
Neither of those actually work
And what about my suggestion posted 6 Jul 06 17:31 ?
 
PHV is correct... neither of those work ... im not in SQL view either...

The solution that PHV gave in his earlier post worked perfectly in my case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top