Calculation Between Form & Subform

Jim W

Registered User.
Local time
Today, 19:31
Joined
Feb 4, 2003
Messages
198
Calculating between a form and sub form

I have a field on a mian form called [avg] I want this field value
to get its data from the subform. There is a field on the subform called total. There can be anywhere from 1 to 15 records in the subform. So what I'm trying to do is add the total from all records in the subform and then divide by the number of records. Should I do the calculation on the subform 1st? How can I get the divide by number of calls?
Thanks Jim
 
You need to make the calculation from the subform's recordsource, I think. Assuming the recordsource is a table - tblSubRecs - I'd write something like

Me.avg = DSum("total","tblSubRecs")/DCount("total","tblSubRecs")

If the subform's recordsource has lots of records you could see performance issues.

HTH--
Jim
 
Thank you that solved my problem
Jim
 

Users who are viewing this thread

Back
Top Bottom