Counting checkboxs

B

blightfoot

I'm trying to count the number of checked check boxes I have in m
table. I can display the records with checked boxes, but when I try t
count them, the query runs, but don't get a number. Here's the SQ
Access wrote for me:

SELECT Count([Cisco Graduates].[640-801 CCNA Attempted]) A
[CountOf640-801 CCNA Attempted]
FROM [Cisco Graduates]
HAVING (((Count([Cisco Graduates].[640-801 CCNA Attempted]))=-1));

Thanks
 
D

Duane Hookom

A yes/no field will contain -1 for true/yes or 0 for false/no. This allows
you to sum the absolute value to tally the number of yes/trues.

SELECT Sum(Abs([640-801 CCNA Attempted])) as NumAttempted
FROM [Cisco Graduates]
 
D

Dale Fye

I'm with Duane.

Your query would have worked fine had it not been for the HAVING clause.
This test (it is really a WHERE clause that fires after the aggregation has
been completed) will check to see whether the number of checkboxes = -1, and
since the count of boxes checked has to be zero or greater, the HAVING
clause can never be met.

If all you want to do is count the records which are checked, you could use
the SQL that Duane posted, or modify yours to:

SELECT Count([Cisco Graduates].[640-801 CCNA Attempted]) AS CountOfAttempts
FROM [Cisco Graduates]
WHERE [Cisco Graduates].[640-801 CCNA Attempted] =-1 ;

HTH
Dale
 
Top