add sum of sub form

bl0u2011

Registered User.
Local time
Today, 23:17
Joined
Dec 23, 2005
Messages
18
Hi everyone,

I am having a bit of problem here,

I have a sub form which listed all the calculated equipment cost
For this I created a query to sum up all the cost field in the sub form
I want to show the sum of those field on the Main form? As the control source of the main form is a table called Job so I can't show the query.

Can anyone help please! I have tried to put the following code in the after update section of subform but it doesn't work Forms![Main]![Text200] = Query![Query1]![SumOfCost]

SQL for sumofcost is as below

SELECT Sum(ElectricalDetails.Cost) AS SumOfCost, First(Job.JobNum) AS FirstOfJobNum
FROM Job INNER JOIN ElectricalDetails ON Job.JobNum = ElectricalDetails.JobNum
HAVING ((([ElectricalDetails]![JobNum])=[Job]![JobNum]));

I have tested SQL and it work fine, just the matter of displaying it on the main form

I have also tried another way of adding the following code on the control source of the text box on the main form

=DSum("[Cost]", "[ElectricalDetails]", "[JobNum] = " & Me.JobNum)

But it doesn't seems to work either


Can anyone help please!
Si
 
Not sure if I am understanding you correctly but....... Your field on the subform [SumofCost] you want to bring to the main form in your unbound [Text200]????
If so... In text 200 put.......
=(NameOfSubform.Form![SumofCost])

I think that should work.
 
Thanks very much it work out well
Cheers
Si
 
Thanks

One more thing if you still there, can I add value from 2 subforms together please!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom