Calculation based on several records in subform

goldriverdancer

Registered User.
Local time
Tomorrow, 03:33
Joined
Jan 4, 2010
Messages
13
Dear all,

I'm getting really confused about how I should go about this. I have a main form and a subform. For each record in the main form, there are several records displayed in the subform.

On the subform, I have a field [Cost]. I want to calculate the sum of this field for all the records in the subform, for each record in the main form; then display it in a textbox. For example, for a particular client, I have several orders in the subform, and I want to calculate the total cost of all the orders.

I don't know if i should use VBA code or a query, or DLookUp to do this. Please help!

Thanks,

Stef
 
Place a textbox in the footer of the subform with the Control Source:
= Sum(Cost)
It won't be visible in the subform in Datasheet mode.

On the main form place another textbox with the control source:
=subformcontrolname.Form!sumtextboxname
This box will show whatever is in the textbox on the subform.
 
Place a textbox in the footer of the subform with the Control Source:
= Sum(Cost)
It won't be visible in the subform in Datasheet mode.

On the main form place another textbox with the control source:
=subformcontrolname.Form!sumtextboxname
This box will show whatever is in the textbox on the subform.

All solved, thanks! I followed your advice for the second part, but i used DLookup to get the sum of specific records (related to one main record in the main form). =)

Stef
 

Users who are viewing this thread

Back
Top Bottom