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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating total in subform

Status
Not open for further replies.

Maldini

Technical User
Nov 10, 2002
55
GB
Hi,
Been working on my database today, but have come across a problem with summing up the costs on my subform. In my orders form, I have a productordered subform in continuous mode, listing the product ordered and the quantity ordered.
On the fly, I have a query which then calculates the cost of product price*quantity, and places this value into txtPrice, a textbox of currency type.

So now, the problem is, things don't seem to be summing up.
I have already placed another textbox, txtTotal in the footer of the subform, with its control source being set to ='Sum([txtPrice]), but unfortunately, its giving me the #Name? error.

With the sum equation , I've tried variations from =Sum([txtPrice]), =NZ(Sum([Price])) and such but with no success.

Anyone know the solution to this problem?
Thanks in advance.

Maldini
 
You have to use a small subform to carry the result of the sum of all Prices * Quantities.
There needs to be two queries to get to the Total Price as one does the calculation of all individual items and the second one takes just the calculated values and sums them all together.
this is the figure that goes into the subform.
 
So this means I would need to have two layers of subforms, one nested within another?

Would you know of any examples around? Since this concept is starting to become a bit too much for me to understand.

Thanks
Maldini
 
No - it is only the queries that are nested but just a single subform - I have samples that are in working applications.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top