Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag 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
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Try:
Assuming chkbxSide1 and chkbxSide2 are fields in tbl

=DCount("chkbxSide1","tbl","chkbxSide1=" & True) + DCount("chkbxSide2","tbl","chkbxSide2=" & True)
You need to use the name of the underlying field, not the name of the check box.

= abs(count(field1) + count(field2))
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.
Avatar of SteveL13

ASKER

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

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

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

Assuming chkbxSide1 and chkbxSide2 are checkbox controls on form.
ASKER CERTIFIED SOLUTION
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That worked.  Thanks.
Welcome!