Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

summing fields on sub forms

Status
Not open for further replies.

HannahLott

Technical User
Apr 26, 2002
7
0
0
GB
I have a main form (TotalStockValue) with four sub forms (AssStock, MatStock, ProStock, ExtStock)on it all the sub forms are datasheets with a footer that contains an unbound textfield called Total with the control source =Sum([ExpectedCost]) format = currency where cost is a field on each of the datasheet sub forms. These text fields are working fine and calculating the sum propably. Then on my main form I have an unbound text field called TotalCost which is meant to add these fields together and display the result but it doesnt work it displays £0.00.

The code I have used is on the on current event as an event procedure and it is:

Me!TotalCost = Forms!TotalStockValue!AssStock!Total + Forms!TotalStockValue!ProStock!Total + Forms!TotalStockValue!MatStock!Total + Forms!TotalStockValue!ExtStock!Total
Me.Repaint

I have tried putting this in the before update event and on load event but it always displays £0.00.

Why?

Thank you in advance, Hannah
 

if the txt box is unbound you could put this in the control source of the totalcost box

sum(Forms!TotalStockValue.form!AssStock!Total + Forms!TotalStockValue.form!ProStock!Total + Forms!TotalStockValue.form!MatStock!Total + Forms!TotalStockValue.form!ExtStock!Total)

Alternative on the on currentevent

me!totalcost = Forms!TotalStockValue.form!AssStock!Total + Forms!TotalStockValue.form!ProStock!Total + Forms!TotalStockValue.form!MatStock!Total + Forms!TotalStockValue.form!ExtStock!Total)

but that will constantly be calculated and could make the form slow

 
Copy and paste in the text box's TotalCost Properties window's ControlSource of main form following string:

=[AssStock].Form![Total] + [ProStock].Form![Total] + [MatStock].Form![Total] + [ExtStock].Form!Total

It must work.
Aivars [pipe]
 
Thank you both I will go and try it out now.

Hannah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top