On Wed, 26 Nov 2003 20:48:30 GMT,
pm*@kershaw.eclipse.co.uk (Phil
Kershaw) wrote:
Is there any way to count the number of times a certain value appears
in a range of fields on one record. I have a table with 25 yes/no
fields in it and would like to count how many yes ticks there are.
Thanks for any help
Here is some aircode that might work for you.
----------------------------------
Private Function Yeses() As Integer
Dim str As String
Dim rst As DAO.Recordset
Dim db As DAO.Recordset
Dim fld As DAO.Field
str = "SELECT * FROM tblMyTable WHERE PK = Something"
Set db = CurrentDb
Set rst = db.OpenRecordset(str)
For Each fld In rst.Fields
If fld.Type = dbBoolean Then
If fld = True Then Yeses = Yeses + 1
End If
Next
Yeses = Abs(Yeses)
End Function
-----------------------------------
Change table name and PK (or ID) to the appropriate ones.
- Jim