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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Novice Question - Null in Query

Status
Not open for further replies.

nifita

IS-IT--Management
Jun 18, 2003
12
US
I'm trying to do what I think ought to be a very simple query. I have one table and I'm using criteria to filter my results in the query.
I first had this, one in each of two fields:
Like "*" & [Enter project no: ] & "*"
Like "*" & [Enter archive type: ] & "*"

That would easily sort by those two fields. However, if the entry in the Project no field was Null, I wouldn't get any of those in my list. So I changed to this:
Like "*" & [Enter project no: ] & "*" Or Is Null
Like "*" & [Enter archive type: ] & "*"

When I left the Project no field empty (Null), it works great and returns all of the archive type selected, regardless of whether project no was null or not.
However, when I enter something in the Project no and in the archive type fields, it returns all those records with a null project type and those that meet the "Like" criteria, when I just want those that meet the "Like" criteria.

Basically, if Project no is left blank, I want the query to filter by
Like "*" & [Enter project no: ] & "*" Or Is Null

If the Project no is filled in, I want it to filter only by
Like "*" & [Enter project no: ] & "*"

I thought maybe I could use Iif for this, but I can't get it to work and I feel like I've tried every combination!
I would greatly appreciate any help...and please speak slowly, I'm new at this :)

 
Try this
Like "*" & [Enter project no: ] & "*" Or [Enter project no: ] Is Null

See if that helps.

Paul
 
Thank you so much! I knew it had to be something simple...who would have guessed that it was THAT simple...now you see what a novice I am :)
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top