Summing multiple checkboxes

R

Robbie Doo

I have a table with a few fields with checkboxes:

ReviewNum CB1 CB2 CB3

0001 Y Y N
0002 N N Y
0003 N Y Y

I would like to create a column in a query where it would list the "Column
Headings" and how many checkboxes are in each column.
Is it possible?
 
A

Allen Browne

Access uses -1 for True (checked) and 0 for False (unchecked.)
You can therefore sum the yes/no fields, and it gives the negative count of
the checked boxes.

In query design, enter an expression like this:
Abs([CB1] + [CB2] + [CB3])

It's clumsy, but that's because this is not the right way to design a
relational database. For more detail, see:
Don't use Yes/No fields to store preferences
at:
http://allenbrowne.com/casu-23.html
 
R

Robbie Doo

Thank you Allen:

I will try to change the table.

Allen Browne said:
Access uses -1 for True (checked) and 0 for False (unchecked.)
You can therefore sum the yes/no fields, and it gives the negative count of
the checked boxes.

In query design, enter an expression like this:
Abs([CB1] + [CB2] + [CB3])

It's clumsy, but that's because this is not the right way to design a
relational database. For more detail, see:
Don't use Yes/No fields to store preferences
at:
http://allenbrowne.com/casu-23.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Robbie Doo said:
I have a table with a few fields with checkboxes:

ReviewNum CB1 CB2 CB3

0001 Y Y N
0002 N N Y
0003 N Y Y

I would like to create a column in a query where it would list the "Column
Headings" and how many checkboxes are in each column.
Is it possible?
 

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