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 gkittelson 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 SubForm

Status
Not open for further replies.

miow

Programmer
Apr 15, 2006
14
GB
Hi there

I have been wrestling all day to just try and simply sum up some fields on form and can't see where I am going wrong. Any help would be greatly appreciated.

Details:

I have 2 forms. One form has the following information:

item no unit price quant totalunitprice


The formula for working out totalunitprice is simply (unitprice*quant). This bit is working fine and I can get the totals for each item number.

What I want to do is then sum up all the totalunitprice fields on a main form. I thought it would simpy be a matter of placing a text box with a control source of =Sum (totalunitprice) similar to excel. This does not seem to work....and is driving me crazy.

Can anybody help please?

Thanks in advance

Miow
 
You will find a bit about this in MSDN: you cannot sum calculated fields. The easiest work around is to sum the calculation:
=Sum(unitprice*quant)
 
In the recordsource of your subform try(use a query)this:

SELECT [tblName].*, [quant]*[unit price] AS totalunitprice FROM [tblName];

In the Form Footer of your subform an unbound textbox called SumTotal with its Control Source:

=Sum(Nz([totalunitprice]))

Then on your Main Form ("sum up all the totalunitprice fields on a main form")an unbound textbox with its Control Source...... =[NameOfYourSubform].Form!SumTotal

 
hi thanks to both remou and ssatech I will give them a go and let you guys know how I get on.

Thank you!

Miow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top