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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple check box counting in a report

Status
Not open for further replies.

Eltoque

Technical User
Jan 12, 2002
21
US
I am trying to count the number of times an item is checked in a question with multiple anweres.
For example:
Record 1:
Option 1 - Checked
Option 2 - Not checked

Record 2:
Option 1 - Checked
Option 2 - Checked.

I want to have the report show:
Option 1 = 2
Option 2 = 1
etc.

I DO know how to get a report to count entries from a list box but I seem to missing some crucial element in getting the code to bring up a number for check boxes.
Here is what I have that is simple and works flawlessly for list boxes:

=DCount("[1]","Table Query","[1] = 'Value'")
Where "1" is the data source (ie. option 1) in the table query and the value is, of course, the value from the list box I am looking to count.

I thought it would stand to reason I could use the same code but I think I am missing how to phrase the "value" of a check box. I know Yes and no is represented as -1 and 0 but I cannot get it to work right.
I have searched the forums and found similar questions but that are far more complex than what I need and my attempts to modify them have failed.
Please help. It seems like such a small thing but it is a road block. Thank you.
 
Did you try using the numeric value and leaving you the double quotes?


=DCount("[1]","Table Query","[1] = -1")
 
Yes, I did. I also tried using the words Yes, On and True to see if I could get it to trigger a response but with no success. I tried it with and without the double quotes. I am at a loss. Is it maybe something I need to do in the query or the table? Am I maybe using the wrong formula?
 
Hmmm
It works in a query

SELECT DISTINCT DCount("[option1]","[tblTest]","option1 = -1") AS Opt1, DCount("[option2]","[tblTest]","option2 = -1") AS Opt2
FROM tblTest;
 
SKO, thank you! I just went in and tried your very first suggestion again, which I tried before but didn't work. This time it did. I can only assume I must have had a misplaced comma or space or something.
Sorry for all the trouble. Thanks to RichUK as well for the suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top