Microsoft Office Tutorials and References
In Depth Information
Adding Subtotals and Totals from Subforms
You can also total a calculation. To come up with the total cost of the items
ordered, use this expression:
= Sum([Qty] * [Unit Price])
If you want to total, average, or count all the records in an entire table
or query, or the selected records in a table or query, use the functions
described in the nearby sidebar “Summarizing lots of records.”
Referring to a control on a subform
To create a control on the main form that shows information from the
subform, you need to know how to refer to a control on the subform. Use this
format for an expression that displays a value from a subform:
= [ subform control name ].Form![ control name ]
This syntax looks hideous, but hold on! Replace subform control name
with the name of the subform control on the main form that displays the
subform, and replace control name with the name of the text box on the
subform that displays the value you want to see.
If your main form is the Orders form shown in Figure 4-7, its subform control
is called Order Details subform. If you want to display the information
from that subform’s Order Subtotal text box, the expression would look
like this:
= [Order Details subform].Form![Order Subtotal]
Creating the controls to total a subform
To calculate a total (or a count) of the values of a control on the subform
and to display it on the main form, you create two controls: one in the form
footer of the subform and one on the main form, wherever you want the total
to appear.
Book IV
Chapter 4
Be careful when entering the expressions for calculating and displaying the
total. In some cases, you type the name of the field; in other cases, you type
the name of the control that displays the field. It can get confusing!
Follow these steps to display the subform total on the main form:
1. Open the subform in Design view, and display its property sheet by
clicking the Property Sheet button in the Tools group on the Design
tab of the Ribbon.
If you already have the main form open in Design view, you can
rightclick the subform control and choose Subform in New Window from the
contextual menu.
Search JabSto ::




Custom Search