Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting Checkboxes

Status
Not open for further replies.

DreamerZ

Programmer
Jul 11, 2001
254
US
I thought this would be pretty easy, but I'm having difficulty.

On a report, I need to count the number of checked checkbox controls. For reference if a checkbox is checked it is equal to -1. I did create a IIF() on each record to confirm this.

Basically, I want to count all the -1's. I created a text box for each record on the report with the IIF function to be 1 if the box was checked and nothing or zero if it wasn't.
Code:
=IIf([Field]=-1,"1","0")
In the report footer and the page footer, I created another text box to add up the contents of that IIf Text box
Code:
=Sum([Text20])
I get an #Error if the Sum Text Box is in the Page footer and a critera input box asking for a Text20 input if it's in the Report Footer.

So, any thoughts?

TIA.

DreamerZ


DreamerZ
simplesolutions@prodigy.net
[ignore][/ignore]
 
You can't Sum() a text box or any other control. You can sum a field. Try:
=Sum(Abs([Field]))
Another issue that I see is returning strings with your IIf() rather than numeric:
=IIf([Field]=-1,1,0)
You could use:
=Sum(IIf([Field]=-1,1,0))
I prefer the simple:
=Sum(Abs([Field]))




Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top