Avatar of SteveL13
SteveL13
Flag for United States of America asked on

How calculate count of checkboxes = True on a form

What is wrong with this code?

Me.txtSides = Count([chkbxSide1]) = True + Count([chkbxSide2]) = True
Microsoft Access

Avatar of undefined
Last Comment
Hamed Nasr

8/22/2022 - Mon
Hamed Nasr

Try:
Assuming chkbxSide1 and chkbxSide2 are fields in tbl

=DCount("chkbxSide1","tbl","chkbxSide1=" & True) + DCount("chkbxSide2","tbl","chkbxSide2=" & True)
mbizup

You need to use the name of the underlying field, not the name of the check box.

= abs(count(field1) + count(field2))
Hamed Nasr

If you mean counting how many checkboxes which are displayed on form for one record, another approach is taken.

Try to upload a demo database showing the issue.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
SteveL13

ASKER
It is on a form and I tried: (which didn't work)

Me.txtSides = Abs(Count(chkbxSide1) + Count(chkbxSide2))

??
Hamed Nasr

If on form, try:
=Abs(chkbxSide1 + chkbxSide2)

Assuming chkbxSide1 and chkbxSide2 are checkbox controls on form.
ASKER CERTIFIED SOLUTION
Hamed Nasr

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SteveL13

ASKER
That worked.  Thanks.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Hamed Nasr

Welcome!