By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Null values are excluded from my parameter query!

P: n/a
I have a search form with a subform that holds the results.
Three text boxes are search criteria:
First Name
Last Name
Address

The criteria in the subform parameter query are like below:
Like "*" & [Forms]![frmPersonLookup]![txtAddress] & "*"

My problem is that if someone is in there with a blank address, there
is no way for me to find them. If i specify their first name
properly, they are still not included in the results. If I go back to
the table and add anything in their address field, they will then show
up in the results.

HELP!

Thanks.
Jan 27 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ni********@hotmail.com wrote in
news:63763522-0e7a-4231-a7be-
f9**********@j78g2000hsd.googlegroups.co
m:
I have a search form with a subform that holds the results.
Three text boxes are search criteria:
First Name
Last Name
Address

The criteria in the subform parameter query are like below:
Like "*" & [Forms]![frmPersonLookup]![txtAddress] & "*"

My problem is that if someone is in there with a blank address,
there is no way for me to find them. If i specify their first
name properly, they are still not included in the results. If I go
back to the table and add anything in their address field, they
will then show up in the results.

HELP!

Thanks.
null is not LIKE anything, nor is null equal to anything, nor is it
unequal to anything.

The only ways out are to convert the null to something or test for
null

add: OR Address is null
to your criteraa
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Jan 27 '08 #2

P: n/a

<ni********@hotmail.comwrote in message
news:63**********************************@j78g2000 hsd.googlegroups.com...
>I have a search form with a subform that holds the results.
Three text boxes are search criteria:
First Name
Last Name
Address

The criteria in the subform parameter query are like below:
Like "*" & [Forms]![frmPersonLookup]![txtAddress] & "*"

My problem is that if someone is in there with a blank address, there
is no way for me to find them. If i specify their first name
properly, they are still not included in the results. If I go back to
the table and add anything in their address field, they will then show
up in the results.

HELP!

Thanks.
Try this:

Like "*" & Nz([Forms]![frmPersonLookup]![txtAddress],"") & "*"

Fred Zuckerman
Jan 27 '08 #3

P: n/a
I tried these and still no luck. They still either display no
records, or will always display the nulls no matter what.
Anything else I can try?
Jan 27 '08 #4

P: n/a
"glockshooter1" <ni********@hotmail.comwrote in message
news:db**********************************@i12g2000 prf.googlegroups.com...
>I tried these and still no luck. They still either display no
records, or will always display the nulls no matter what.
Anything else I can try?
You're right: as Bob Quintal explained, Null doesn't match anything.

Switch the query to SQL View (View menu.)

In the WHERE clause, you will see something like this:
WHERE (([SomeField]) Like "*" &
[Forms]![frmPersonLookup]![txtAddress] & "*") AND ...

Change it like this:
WHERE (([Forms]![frmPersonLookup]![txtAddress] Is Null) OR
([SomeField] Like "*" & [Forms]![frmPersonLookup]![txtAddress] &
"*")) AND ...

Watch the brackets: they're important when you mix AND and OR.

How it works
=========
A WHERE clause is an expression that evaluates to True or False or Null for
each record. Only the records where it is True are included. Therefore we
craft the expression to return True for all records when the text box is
null.

When the text box is null, the expression:
([Forms]![frmPersonLookup]![txtAddress] Is Null)
is True, and the expression:
[SomeField] Like "*" & [Forms]![frmPersonLookup]![txtAddress] & "*")
is Null.

The result of an OR is True if either part is True (regardless of the other
part.) So when the text box is null, this expression yields True ('coz the
first part is true), regardless of what is actually in the field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

Jan 28 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.