ACC: How to Bring a Subtotal from a Subform to a Main FormID: Q119134
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article demonstrates how to correctly reference a subtotal control on
a subform from a main form.
NOTE: This article explains a technique demonstrated in the sample
files, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0)
and FrmSmp97.exe (for Microsoft Access 97). For information about how
to obtain these sample files, please see the following articles in the
Microsoft Knowledge Base:
Q150895 ACC95: Microsoft Access Sample Forms Available on MSL
Q175066 ACC97: Microsoft Access 97 Sample Forms Available on MSL
If you try to sum a subform field using a calculated control on a main
form, you may receive an error message in the main form control. For
example, the following expression in a main form control generates a
"#Name?" error message:
=Sum([MySubForm].Form![ExtendedPrice])
Text Box Control
Name: OrderSubtotal
ControlSource: =Sum([ExtendedPrice])
Text Box Control
Name: Order Subtotal
ControlSource: =Sum([Extended Price])
Text Box Control
Name: Subtotal
ControlSource: =[OrdersSubform].[Form]![OrderSubtotal]
Text Box Control
Name: Subtotal
ControlSource: =[Orders Subform].[Form]![Order Subtotal]
For more information about referencing subform controls, search for "subforms," then "referring to in expressions," and then "Calculate a total in a subform and display it on a form" using the Microsoft Access Help Index.
Additional query words: totals
Keywords : kbusage FmsHowto
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 6, 1999