Totaling fields in a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a form with a subform (that is a continuous form). In the
form are fields that I want to show running totals of the corresponding
detail in the subform. In other words, in the subform I have a field called
Qty. On the (main)form I have a field called AccumQty that I want to display
the running total from all the records in the corresponding detail Qty field.

I've been playing around with queries but have not arrived at a solution.
I'm sure this is not a new issue. Any suggestions?

Thanks,

JT
 
JT said:
I have created a form with a subform (that is a continuous form). In
the form are fields that I want to show running totals of the
corresponding detail in the subform. In other words, in the subform
I have a field called Qty. On the (main)form I have a field called
AccumQty that I want to display the running total from all the
records in the corresponding detail Qty field.

I've been playing around with queries but have not arrived at a
solution. I'm sure this is not a new issue. Any suggestions?

The easiest way is to give your subform a Form Footer section, if it
doesn't already have one, and then add text boxes to that section for
the totals. These text boxes will use the Sum() function in their
controlsource properties to calculate the totals. For example, you
might add a text box named "txtTotalQty", and give it the controlsource

=Sum(Qty)

Now, you can choose to just display these text boxes in the form footer,
or you can hide them all by making the form footer section invisible
(set its Visible property to No) and still have text boxes on the main
form that pull their values from the text boxes on the subform. For
example, your "AccumQty" text box (on the main form) would have a
controlsource of

=[YourSubformName].Form![txtTotalQty]

You need to replace "YourSubformName" in the above expression with the
name of the subform control -- on the main form -- that is displaying
the subform.
 
Back
Top