Add results from fields in a form

S

smeldawg

I have a form that contains 18 fields from one table. They all containd drop
downs allowing the user to select yes, no or n/a. How can i count the number
of yes in these 18 fields in a separate field?
 
D

Douglas J. Steele

Are these 18 different fields in one row, or 1 field in 18 different rows?

For the former (which, by the way, makes me question the validity of the
data model), you can add a computed field in a query that sums together the
18 fields. True is stored as -1, while False is stored as 0. That means that
Abs(Nz([Field1], 0) + Nz([Field2], 0) + Nz([Field3], 0) + ... +
Nz([Field18], 0)) will be the number of True values in the row.

For the latter, you can use DCount("*", "MyTable", "MyField = True"), or a
Totals query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top