Criteria Question (1 Viewer)

bsdixon

Registered User.
Local time
Today, 06:28
Joined
Nov 13, 2003
Messages
62
I have a query with criteria captured from two fields in a form.

For example:
[Forms]![ScaleLogSpreadsheet]![ComboName]
[Forms]![ScaleLogSpreadsheet]![ComboBatch]

How do I get the criteria to work so that it shows all records if both fields are blank and also works if one of the fields is blank. I believe that I need to use IsNull, but I do not know where to put this in my criteria.

Thanks.
 

Dreamboat

Smack in the Middle
Local time
Today, 01:28
Joined
Jun 24, 2000
Messages
106
=isnull([field name 1]) or isnull([field name 2])

(I think!)


You don't need the AND, because if they're BOTH null, then the OR already handles them.
 

bsdixon

Registered User.
Local time
Today, 06:28
Joined
Nov 13, 2003
Messages
62
I have the following in my criteria and it does not not show any records when I leave the combo field blank.

What am I doing wrong?

[Forms]![ScaleLogSpreadsheet]![ComboName] or IsNull([Forms]![ScaleLogSpreadsheet]![ComboName])


Thanks.
 

Dreamboat

Smack in the Middle
Local time
Today, 01:28
Joined
Jun 24, 2000
Messages
106
Something else wrong with your query then. But the one you have there isn't any good. It's like not having ANY criteria 'cause you're asking to have it whether it's null or not...

Need to send your DB? I'll give it a go. anne@vbaexpress.com
I'm not very good without seeing the DB...some people can do that. I'm way bad at it.
 

DALeffler

Registered Perpetrator
Local time
Yesterday, 23:28
Joined
Dec 5, 2000
Messages
263
Try:

Like [Forms]![ScaleLogSpreadsheet]![ComboName]&"*"
Like [Forms]![ScaleLogSpreadsheet]![ComboBatch]&"*"

Each of these criteria statements should go under seperate columns in the query design grid while staying on the same horizontal "Criteria:" row.
 

bsdixon

Registered User.
Local time
Today, 06:28
Joined
Nov 13, 2003
Messages
62
Doug, I tried that code, but when the combo box is blank the query does not show any records.

What criteria do I need so that when the combo box is blank, all records come up?
 

DALeffler

Registered Perpetrator
Local time
Yesterday, 23:28
Joined
Dec 5, 2000
Messages
263
That should have returned all records when either form field is empty. Do you have any other criteria in the query?
 

Users who are viewing this thread

Top Bottom