Totaling 2 subforms on a form

T

talofer

I have a form that has 2 subforms on it. each subform has a separate total.
How do I display on the form the "grand total"

Thanks,
 
D

Darren Evans

You could try placing a text box in the part of the form where you want the
Grand total to appear and leave it empty. Call it txtGrandTotal (for example)

One of the events in the forms properties needs to trigger the Grand total.
Let's say for arguments sake it's the OnOpen event:

Private Sub Form_Open(Cancel As Integer)

txtGrandTotal = Forms!Subform1!Field1 + Forms!Subform2!Field1

End Sub

This will generate the total everytime and populate the required field. You
may have to try OnCurrent also to see which one is most effective. Try iy!!

Daz
 
T

talofer

Daz,
Thanks for your help.
I did what you suggested, and I am getting a #Name? error
What's this? does this mean i miss spelled one of the total names?
Thanks, Ofer
 
D

Darren Evans

Yeah - normally this refers to the names referenced in the code. Try adding
the [] brackets below. This should work but like I say it may need to be
generated by another event. Alternatively, try entering the right hand side
of the entry below in the Control Source of the text box where you want your
total to appear (remembering the = sign!!)

[txtGrandTotal] = Forms![Subform1]![Field1] + Forms![Subform2]![Field1]
 
Top