Put a textbox on your subform in the footer.
Call it something like Total and put the =Sum([Fieldname]) in it's control source.
Then put a unbound text box on the main form.
Its control source will be the textbox on the subform.
Me![SubformName]!Total
After you have the formula working make the textbox on the subform invisible.
DougP, MCP
dposton@universal1.com
Ask me how Bar-codes can help you be more productive.
The hypothetical situation is: On the sub-form each line has an amount & you want to show the sum of all line amounts on the main form.
1) On your sub-form create a sum control in the sub-form footer, like:
Name:[tab]SubFormTotal
Control Source: = Sum([Amount])
Visible:[tab]False
2) On the main form... create a control to reference the totaling control of the subform... err, that's the one you just created. Sooooooo
Name:[tab]ShowTotalFromSubform
Control Source: =[>>Insert Sub-Form Name<<].Form![SubFormTotal]
As long as you reference the full name of the sub-form's control you can perform any number of calulations on that "Sum()" from the sub-form. & it works for reports too.
i do something like... where i lifted the code
Sub-report:
Name: PAFSubReport
Sub-report's Control:
Name: DocTot
Control Source: =Sum([Amount])
Main report's control: 'shows one month of salary
Control Source: =IIf([PAFLayout]="A",[PAFSubReport].Report![DocTot]/12)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.