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

Counting Check Boxes in a query 1

Status
Not open for further replies.

NETHROW

Technical User
Oct 18, 2002
12
US
My table has several check boxes in it. In the query totals I have COUNT as my operator but it counts every record in my table, How do i get it to only count Boxes that are checked?
 
Every checkbox tends to have a value, so counting them basically gives you the number of records. If the checkbox is checked (True) the value is -1, whereas if the checkbox is empty (False) the value is 0. One way to count how many of the values is true is to SUM the checkbox field, then take the absolute value, or simply (-SUM(checkboxfield)). Make this the data source for the control in your report or form.

-Larry
 
Here is a method I use. In the query use this...

Count CheckBoxes: Sum(IIf([Table Name ChkBox]=True,1,0))

Make sure that the "Total" line in your query is set to "Expression".

TommyP

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top