Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 639
  • Last Modified:

sum of values in checkboxes

I have 8 checkboxes fields in a table chk1, chk2, etc.

I would like, in a query, sum up all the 8 checkboxes for each row counting one for the checked ones and zero for the unchecked.

Any idea?

I tried chk1+chk2 but I always get zero...
1 Solution
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Since in Access True = -1 and False = 0, if you do a [chk1]+[chk2] etc. it should return the negative value of how many were checked.   Then just do an abs([chk1]+[chk2]) to convert it to a positive number.  

Also, if your check box is a triple state, meaning it can contain NULL values, [chk1] is going to have to change to Nz([chk1],0) to convert the NULL values to zero, so you can do the math.

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now