Not operator

Melanie

Board Regular
Joined
Sep 17, 2003
Messages
51
Can someone please explain to me why this problem is occurring to me when I am working with a text field in a query.

For example if the field contains first names and I enter in the criteria "john", and run the query, then the result is all the records that contain the first name john.

HOWEVER, when I try using any type of not condition (ie not, <>, not like, not in) I receive no records for the output, and there are certainly other first names in the table.

Please help.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
It should work if you enter the criteria like:

Not "John"

If it doesn't, be sure to check that you don't have any other criteria interfering with this criteria.
 
Upvote 0
I had tried entering that, but it did not work. And that is the only criteria I have with the query.

Do you have any other suggestions?

thanks.
 
Upvote 0
What happens if you create a brand new query with only this one field in it, then type in this one criteria. Does it work?

If not, can you specify the field specs of the field you are trying to do the query on and list some samples of the data?
 
Upvote 0
I think I was able to figure it out.

All the other records are blank. For example the field either contains the name "John" or is null. So in the criteria I simply typed "is null" and it gave me all of the non-john records.

But still, I thought that if I used the not criteria that should give me the same answer...
 
Upvote 0
No, unfortunately Null fields are handled differently. If you want to check for a value not being equal to something, and there may be null fields, then you need to use format:

Not "criteria" Or Is Null
 
Upvote 0

Forum statistics

Threads
1,221,596
Messages
6,160,711
Members
451,665
Latest member
PierreF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top