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!

Too many records missing after query applied

Status
Not open for further replies.

jvleigh221

IS-IT--Management
Oct 27, 2006
9
0
0
US
Here is the SQL in a generic form:

SELECT TABLE.FIELD1, TABLE.FIELD2, TABLE.FIELD3
FROM TABLE
WHERE (((TABLE.FIELD3)<>"CRITERIA1" And (TABLE.FIELD3)<>"CRITERIA2" And (TABLE.FIELD3)<>"CRITERIA3" And (TABLE.FIELD3)<>"CRITERIA4"));

This SQL statement is used as an Access form's Record Source.

However, now the records that may have an empty or null value for Field3 are excluded, as well.

Any suggestions are apprciated.
 
You could enclose the entire existing WHERE clause in parens, and then append OR IS NULL.

Also, you could use the below WHERE clause example:
where trim("" & TABLE.FIELD3)<>"CRITERIA2"
...etc.

The Trim("" & [field]) takes care of nulls and ""
-Jim
 
I tried the trim and it did the same this. It excluded all record with an empty string.

I need to make sure they are not excluded.

thanks
 
And what about this ?
SELECT TABLE.FIELD1, TABLE.FIELD2, TABLE.FIELD3
FROM TABLE
WHERE Nz(TABLE.FIELD3,'?') Not In ('CRITERIA1','CRITERIA2','CRITERIA3','CRITERIA4');

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I re-examined the code and with some extra help it worked when I did the following:

WHERE (((TABLE.FIELD3)<>"CRITERIA1" And (TABLE.FIELD3)<>"CRITERIA2" And (TABLE.FIELD3)<>"CRITERIA3" And (TABLE.FIELD3)<>"CRITERIA4")) Or (((TABLE.FIELD3) Is Null));

Thanks to all who helped.

Jeremy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top