control in access report

L

LP

Is it possible to use the division operator in control source?
For example, using
=DCount("[Field1]","qryX","[Field1]=True")+DCount("[Field2]",qryX","[Field2]=True")......+DCount("[Field6]","qryX","[Field6]=True")
and then I want to divide the number, in the same control, by the number of
fields (6 in the example) to obtain the average.
regards
 
A

Allen Browne

Yes. You can use / as a divisor, e.g.:
=(DCount(...)+ ...) / 6

Since True is -1 and False is zero, you could also sum the fields to get the
negative count of the Yeses. This might be a more efficient approach, e.g.:
=Abs(DSum("[Field1]+[Field1]+[Field3]", "qryX")) / 3

In general, lots of yes/no fields that you want to sum like that probably
indicates that you don't have a relational data structure. More info:
Don't use Yes/No fields to store preferences
at:
http://allenbrowne.com/casu-23.html
 

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