How to sum a text box located in a subform

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

Guest

I have a form called OrderRequest that contains a text box called
TotalClothingPieces. The OrderRequest form also contains a subform called
ClothingItems. The subform is displayed in the datasheet view and has three
columns one called Quantity.

After the user inserts a value in the Quantity column (located in the
subform), I want my TotalClothingPieces text box to update with the
appropriate value. For example, if the sum value in the Quantity column is
10 then I was that value to be displayed in the TotalClothingPieces text box.


Please tell me how to do this.

Thanks in advance.
 
HL,
In subform design view, add an unbound text control in the FormFooter to
calculate the sum of all Quantity values in the subform. (Quantity is
assumed to be a bound text control with an entered value... not a calculated
field)
=Sum(Quantity)
Quantity is assumed to be a bound text control with an entered value...
not a calculated field.
Call that sum field TotalClothingQuantity.

On the Main form, place an unbound calculated field with a ControlSource
of...
= Forms!OrderRequest!ClothingItems.Form!TotalClothingQuantity
 
I have a form called OrderRequest that contains a text box called
TotalClothingPieces. The OrderRequest form also contains a subform called
ClothingItems. The subform is displayed in the datasheet view and has three
columns one called Quantity.

After the user inserts a value in the Quantity column (located in the
subform), I want my TotalClothingPieces text box to update with the
appropriate value. For example, if the sum value in the Quantity column is
10 then I was that value to be displayed in the TotalClothingPieces text box.

You'll need to put a control (which need not be visible) in the
subform's Footer. Let's say you name it txtTotalQuantity. Set its
Control Source to

=Sum([Quantity])

Then, set the control source of TotalClothingPieces to

=mysubformname.Form!txtTotalQuantity

Note that TotalClothingPieces should generally NOT be stored in your
table - just calculate it as needed.

John W. Vinson[MVP]
 
Back
Top