Not Null Query (1 Viewer)

LarryE

Active member
Local time
Today, 01:00
Joined
Aug 18, 2021
Messages
586
This is what I'm looking for... Seems like it's still not clear. Sorry.
In my query, I don't want to see records that have ALL three fields with a value.
If ALL three have a value in those fields, I do not want that record returned.
All other combinations I want to see those records.
See my answer above
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:00
Joined
Feb 19, 2002
Messages
43,257
Try this one:
query4:
SELECT Table1.id, Table1.fld1, Table1.fld2, Table1.fld3
FROM Table1
WHERE NOT (Table1.fld1 Is Not Null AND Table1.fld2 Is Not Null AND Table1.fld3 Is Not Null)
OR (Table1.fld1 Is Null AND Table1.fld2 Is Null AND Table1.fld3 Is Null)

And remember, if the field contains a ZLS it is still "empty" but it is not null and will not be treated correctly in the expression

I'm sure there is a better way to do this but I'm done. I've spent enough time on it. I updated the sample database to include the fourth query.
 

Attachments

  • ComplexCondition2.accdb
    444 KB · Views: 71

kitty77

Registered User.
Local time
Today, 04:00
Joined
May 27, 2019
Messages
712
Try this one:
query4:
SELECT Table1.id, Table1.fld1, Table1.fld2, Table1.fld3
FROM Table1
WHERE NOT (Table1.fld1 Is Not Null AND Table1.fld2 Is Not Null AND Table1.fld3 Is Not Null)
OR (Table1.fld1 Is Null AND Table1.fld2 Is Null AND Table1.fld3 Is Null)

And remember, if the field contains a ZLS it is still "empty" but it is not null and will not be treated correctly in the expression

I'm sure there is a better way to do this but I'm done. I've spent enough time on it. I updated the sample database to include the fourth query.
Looks like Query4 did the trick. Thank You!
 

Users who are viewing this thread

Top Bottom