Part I: Access Building Blocks
370
You may find that Access complains about a circular reference on the Category text box after
you change the control’s ControlSource. This happens because the name of the control is
Category, and the text box is bound to a field named Category. Access doesn’t understand that
[Category] in the expression you entered as the ControlSource actually refers to the field,
not the text box. (A text box’s value can’t be based on the text box’s contents — that’s the defini-
tion of circular reference.) The solution is to rename the text box to txtCategory to distinguish it
from its bound field.
Caution
When you create a bound control, it uses the name of the data field as the default control name. Using the
control in an expression without changing the name of your control, causes circular references. You must man-
ually rename the control to something other than the original field name. This is another reason why a simple
naming convention, such as prefixing text boxes with txt, is such a good idea. You’ll avoid a lot of nagging
problems by adopting a naming convention for the controls on your Access reports.
Follow these steps to complete the expression and rename the control:
- Select the Category control in the Category Group Header section and display the
property window for the control. - Change the ControlSource property to =“Category: “ & [Category].
- Change the Name property to txtCategoryDisplay.
Enhancing the Detail section
The Detail section is in fairly good shape. Make sure the Description control is slightly indented
from the Category expression in the Group Header. A label should be created, as shown in Figure
9.37, identifying the values in the Cost and Retail Price controls.
A line is also good to add to this Detail section to separate one record from another. This is often
done when records occupy varying space within a group. Some records are shorter than others,
and the separation between records might not be obvious to users.
Because you don’t want two lines at the bottom of each page (you add a line to the Page Footer
next), you put this line at the top of the Detail section:
- Select the Line tool in the Controls ribbon group.
- Place the cursor near the far left side of the Detail section, just to the right and above the
(^1) ⁄ 8 -inch mark on the vertical toolbar.
You may have to reposition controls in the Detail section to make room for the horizontal
line.
- Hold down the Shift key and drag the line across the page header, releasing the mouse
button just to the left of the 7^1 ⁄ 2 -inch mark. - Select the line and set BorderWidth property to 1 pt or 2 pt.