The information in this article applies to:
SUMMARY
Moderate: Requires basic macro, coding, and interoperability skills.
MORE INFORMATION
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:
To avoid an error, you can sum the subform field using a calculated control in the subform's form footer. You can then reference the calculated control from the main form to display the summed value. This technique is demonstrated in the Orders form of the sample database Northwind.mdb in Microsoft Access 7.0 and 97 and NWIND.MDB in Microsoft Access 1.x and 2.0. The Orders Subform contains a calculated control in the subform's form footer. This calculated control sums the subform's Extended Price field to create a subtotal using the following syntax: In Microsoft Access 7.0 and 97:
In Microsoft Access 1.x and 2.0:
Because the subform's DefaultView property is set to Datasheet, you do not see the calculated control in the subform's form footer when you open the Orders form in Form view. However, a text box control on the main form refers to the subform's calculated control and displays its value. The main form control is called Subtotal and references the subform's calculated control using the following syntax: In Microsoft Access 7.0 and 97:
In Microsoft Access 1.x and 2.0:
This reference allows the main form to display a subtotal of a subform field while the actual totaling of subform values is performed using a calculated control in the subform's form footer. REFERENCESFor 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 |
Last Reviewed: November 2, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |