Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Counting check boxes on a report


Message #1 by "Peter F Pennells" <ppenn@b...> on Wed, 28 Feb 2001 22:24:48 -0000
I have a form that incorporates approximately 50 check boxes that are bound

to a table.

I have designed a query to interogate the table and this query I want to be

the basis for a report.

I can get the report to show all the necessary info but want I want it to do

in addition is count the number of tocked check boxes in a row, in other

words all those with a value of '-1'

I am having great difficulty in solving this problem, has anyone got any

ideas

many thanks

Peter



Message #2 by "Pardee, Roy E" <roy.e.pardee@l...> on Wed, 28 Feb 2001 14:48:39 -0800
It'd be ugly, but a VBA function would probably work.  Something like:



' ===========================================

' THIS IS UNTESTED!!!

Public Function CountChecks(ParamArray varIn() As Variant) As Integer

Dim varLoop As Variant

Dim intReturn As Integer

   intReturn = 0

   

   For Each varLoop In varIn()

      If VarType(varLoop) = vbBoolean Then

         If CBool(varLoop) = True Then intReturn = intReturn + 1

      End If

   Next varLoop



CountChecks = intReturn

End Function

' ===========================================



You could call this from your query (and here's the ugly part) like so:



SELECT *, CountChecks(fld1, fld2, fld3, fld4, ...., fld50)

FROM tblMyTable ;



HTH,



-Roy



-----Original Message-----

From: Peter F Pennells [mailto:ppenn@b...]

Sent: Wednesday, February 28, 2001 2:25 PM

To: Access

Subject: [access] Counting check boxes on a report





I have a form that incorporates approximately 50 check boxes that are bound

to a table.

I have designed a query to interogate the table and this query I want to be

the basis for a report.

I can get the report to show all the necessary info but want I want it to do

in addition is count the number of tocked check boxes in a row, in other

words all those with a value of '-1'

I am having great difficulty in solving this problem, has anyone got any

ideas

many thanks

Peter


  Return to Index