Count check box yes/no

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with yes/no checkboxes. I want to be able to count the number
of times yes is checked in a field.

I have created a query that counts the fields, but it count all checkboxes,
not just the ones that have been checked yes.

Does anyone have any ideas?
 
Use the Sum aggregate function. When a checkbox is checked, its numeric
value is -1 (which is how ACCESS represents True or Yes). Using the Abs
function changes the negative sign to plus so that you get a positive number
as the result.

NumberChecked: Abs(Sum([CheckboxFieldName]))


Or as an SQL example:

SELECT Abs(Sum([CheckboxFieldName])) AS NumberChecked
FROM TableName;
 
Use the Sum aggregate function. When a checkbox is checked, its numeric
value is -1 (which is how ACCESS represents True or Yes). Using the Abs
function changes the negative sign to plus so that you get a positive number
as the result.

NumberChecked: Abs(Sum([CheckboxFieldName]))

Or as an SQL example:

SELECT Abs(Sum([CheckboxFieldName])) AS NumberChecked
FROM TableName;
--

Ken Snell
<MS ACCESS MVP>






I have a table with yes/no checkboxes. I want to be able to count the
number
of times yes is checked in a field.
I have created a query that counts the fields, but it count all
checkboxes,
not just the ones that have been checked yes.
Does anyone have any ideas?


There is another interesting way to count Yes fields. Add in query
field:

NoOfYes: -Sum([YesNoField])

Turn on Totals and set field as Expression.

Regards,
Branislav Mihaljev
 
Back
Top