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

Display 0 when counting yes/no field

Status
Not open for further replies.

Arob

Technical User
Jul 25, 2001
55
0
0
US
I have the below query which counts the number of true values in the exclude location field in the orignal list table. However, how can you get the query to display zero value for a yes/no field?

SELECT Count([Original List].Excludelocation) AS CountOfExcludelocation
FROM [Original List]
WHERE ((([Original List].Excludelocation)=True))
GROUP BY [Original List].Blitzlocations
HAVING ((([Original List].Blitzlocations)=[Forms]![FrmMenuReports1]![blitzlocations]));

Thanks

 
Try:

Code:
SELECT Nz(Count([Original List].Excludelocation),0) AS CountOfExcludelocation
FROM [Original List]
WHERE ((([Original List].Excludelocation)=True))
GROUP BY [Original List].Blitzlocations
HAVING ((([Original List].Blitzlocations)=[Forms]![FrmMenuReports1]![blitzlocations]));
 
The query still comes up with no results when their is only false results, I expect since the yes/no is not a null function, than the Nz function will not work.
 
Oops. You're right--the query won't work. You should be able to get the result you're looking for like so:

Code:
Nz(DCount("Excludelocation","Original List","Blitzlocations = " & forms!frmMenuReports1!blitzlocations & " AND Excludelocation = True"), 0)

THIS should return 0 if all checkboxes are FALSE.

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
It wants to always give me a zero. Just wandered if you had a clue as to why it wants to do this?
 
Maybe blitzlocations is a text field and not a numeric field? In that case, surround the value with quotes like so:

blitzlocations='insidequotes'

so the function becomes:

Code:
Nz(DCount("Excludelocation","Original List","Blitzlocations = '" & forms!frmMenuReports1!blitzlocations & "' AND Excludelocation = True"), 0)

--
Find common answers using Google Groups:

Corrupt MDBs FAQ
 
No luck, it still does the same. I will continue to mess around with it. If you happen to think of anything else let me.

Thanks for all the help. Arob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top