Using NZ Function to return ALL records

G

ghetto_banjo

In my query, I am using the NZ function to look at a field on a form,
and if that field is blank I want the query to act like there is no
criteria at all.

Here is my function

Like nz(Forms!frmSearch.txtOrderCategory, "*")


This almost works perfectly. Currently, the query will pull orders
with the specified order category if that field is filled in, or if
the field is blank, it will pull all orders that HAVE an order
category. Some orders do not have a category specified, and these are
not returned. In other words the "*" means all records that have
anything but null. I want to also include the nulls when the field is
blank, how do I accomplish this?
 
S

Stefan Hoffmann

hi,

ghetto_banjo said:
In other words the "*" means all records that have
anything but null. I want to also include the nulls when the field is
blank, how do I accomplish this?
Add this to your criteria:

OR (IsNull(Forms!frmSearch.txtOrderCategory) AND IsNull([yourField]))


mfG
--> stefan <--
 
G

ghetto_banjo

Still is only grabbing the non-null values. maybe i do not have it
set up properly.


Like nz([Forms]![frmSearch].[txtOrderCategory],"*") Or (IsNull([Forms]!
[frmSearch].[txtOrderCategory]) And IsNull([tblOrders.Category]))



seems like those IsNull statements are just going to return booleans
and not specify it to return null values as well? I dont know....
 
G

ghetto_banjo

By default, when you open a form and an unbound text box is "blank",
is it a zero-length string or is it Null?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top