Working with Totals
Let's
revisit the footers we have created long enough to add totals. We have aligned
our various levels of grouping adequately to make this an efficient exercise.
The totals that we insert will be group summaries, and, as such, are contextually
sensitive to the section into which we insert them. The expression in a
field that yields a summary at a given group level will also yield the correct
summary when placed in another group level (respective of the level in which it
is placed); it "knows" its location and, as we shall see, behaves
accordingly.
We
will start with the OrderDate footer section then work our way outward
in summary creation, just as we did in the creation of the groups themselves.
1.
Click the ToolBox
button to cause the ToolBox to appear.
The ToolBox
button is depicted in Illustration 32.
Illustration 32:
The ToolBox Button
The
Controls ToolBox appears, as shown in Illustration 33.
Illustration 33:
The Controls ToolBox
2.
Click the Text
Box control (shown circled in red in Illustration 33 above).
3.
Place the
mouse cursor within the OrderDate footer.
The
cursor becomes a "+" ("crosshairs") sign, to assist
us in placing the new control.
4.
Click at the
point of insertion of the top left corner of the control.
5.
Try to place
the control under the NetOrder field just above the OrderDate
footer, by drawing a rectangular outline approximately its size under the NetOrder
field.
6.
Click the Label
control that has appeared to the left of the new text control.
7.
Press the Delete
key.
The Label
control disappears.
8.
Adjust the
alignment of the new Text control as closely as possible with the NetOrder
field by resizing and dragging as appropriate.
9.
Right-click
the new Text control.
10.
Select Properties.
The Properties
sheet appears, defaulted to the Format tab.
11.
Select Currency
in the Format field.
The Properties
sheet - Format tab for the new Text control appears as depicted
in Illustration 34.
Illustration 34: Properties sheet
- Format Tab for the New Text Control
NOTE: The
new Text control, like all new controls, is assigned an identifying name
by MS Access upon creation ("Text21" in Illustration 34). In
general, we would assign logical names to the controls based upon corporate or
project standards that made sense to us at the point of creation. We will
leave these identifiers at default for purposes of this lesson, in the interest
of brevity, but proper naming is, without doubt, an important attribute in
organizing and maintaining the object set in any real world project.
12.
Click the Data
tab.
13.
Type the
following into the Control Source field:
=Sum([NetOrder])
The Properties
sheet - Data tab appears as shown in Illustration 35.
Illustration 35: Properties sheet
- Data Tab for the New Text Control