Just as reports have properties, so do controls. You can change most control properties at design time or at runtime; this allows you to easily build flexibility into reports. For example, certain controls are visible only when specific conditions are true. The following sections discuss the Format properties of a control and the Data and Other properties of a control.
The Format properties of a control allow you to customize the appearance of the control. By using the Format properties, you can modify control attributes such as the back color, font, special effect, and text alignment of the control. You can modify many of the Format properties of selected objects by using the Formatting toolbar (see Figure 17.2). If you prefer, you can set the Format properties in the Properties window (see Figure 17.3). The following sections discuss the Format properties that are available.
The Format property determines how Access displays the data in a control. This property is automatically inherited from the underlying field. If you want the control's format on the report to differ from the underlying field's format, you must set the Format property of the control. It's important to note that the Format options available vary based on the field type of the underlying field. In other words, the Formatting options vary if the underlying field is a Text field versus a Number field.
The Caption property specifies the text displayed for labels and command buttons. A caption is a string that contains up to 2,048 characters.
The Hyperlink Address property is a string representing the path to a UNC (network path) or URL (Web page). Command buttons, image controls, and labels all contain the Hyperlink Address property. Therefore, if you attach a hyperlink for your company's Web page on a command button, the user can click the button to be taken to that Web page.
The Hyperlink SubAddress property is a string that represents a location within the document specified in the Hyperlink Address property. Command buttons, image controls, and labels all contain the Hyperlink SubAddress property.
The Decimal Places property defines the number of decimal places displayed for numeric values.
The Visible property determines whether a control is visible. You can use this property to toggle the visibility of a control in response to different situations.
The Hide Duplicates property hides duplicate data values in a report's Detail section. Duplicate data values occur when one or more consecutive records in a report contain the same value in one or more fields. Figure 17.4 shows a report with the Hide Duplicates property set to its default value, False. Notice the duplicate sales person values. Figure 17.5 shows the same report with the Hide Duplicates property set to True. Notice that the duplicate sales person values no longer appear.
When the Can Grow property is set to Yes in a control, the control can expand vertically to accommodate all the data in it. The Can Shrink property eliminates blank lines when no data exists in a field for a particular record. For example, if you have a second address line on a mailing label, but there's no data in the Address2 field, you don't want a blank line to appear on the mailing label (see Figure 17.6). You must therefore set the Can Shrink property for the Address2 control to Yes (see the results in Figure 17.7). Likewise, if you have a memo that sometimes has only one line of data but at other times has multiple lines of data, you might want to set the Can Grow property to Yes so that the control grows as necessary.
The Left, Top, Width, and Height properties set the size and position of the controls on a report.
You can set the Back Style property to Normal or Transparent. When this property is set to Transparent, the color of control. When it is set to Normal, the control's Back Color property determines the object's color.
The Special Effect property adds 3D effects to a control.
The Border Style, Border Color, and Border Width properties set the physical attributes of a control's border.
The Fore Color property sets the color of the text within a control.
The Font Color, Font Name, Font Size, Font Weight, Font Italic, and Font Underline properties affect the appearance of the text within a control.
The Text Align property sets the alignment of the text within a control. You can set this property to Left, Center, Right, or Distribute. When it is set to Distribute, text is justified (see the Product Name column in Figure 17.8).
The Reading Order property determines the visual order in which characters, words, and groups of words are displayed. This property is often used with language-specific editions of Microsoft Access for which the reading order needs to be changed. The default setting is Context; Left-to-Right and Right-to-Left are the other available settings.
The Scroll Bar Align property specifies the visual placement of the control's vertical scrollbars and buttons. This property works in conjunction with language-specific versions of Access to determine scrollbar placement in either the right-to-left or left-to-right directions. The default setting is System, which lets the operating system determine the scrollbar alignment.
The Numeral Shapes property determines the format for displaying numeric characters. This property works in conjunction with language-specific versions of Access to determine the type of numeric character to display. The default setting is System, which lets the operating system determine the numeric character display format. The other settings are Arabic, National, and Context.
The Left Margin, Top Margin, Right Margin, and Bottom Margin properties are used to determine how far the text within a control prints from the left, top, right, and bottom of the control, respectively. These properties are particularly useful for large controls that contain a lot of text, such as memo on invoices.
The Line Spacing property is used to control the spacing between lines of text within a control. The Line Spacing property is designated in inches.
The Is Hyperlink property is used to determine whether Access displays the text within a control as a hyperlink. If you set the Is Hyperlink property to Yes and the text within the control is a relevant link, the text serves as a hyperlink. (This is useful only if you save the report in Hypertext Markup Language [HTML] format.)
The Data properties of a control (see Figure 17.9), described in the following section, specify information about the data underlying a particular report control. By using the Data properties, you can designate everything from what data displays in a control to whether the data sums as it displays.
The Control Source property specifies the field in the report's record source that's used to populate the control. An example would be FirstName. A control source can also be a valid expression.
The Input Mask property assigns specific formatting to any data that is entered into a particular control. For example, you could use the input mask (999) 000-0000 to format data entered as a phone number.
The Running Sum property (which is unique to reports) is powerful. You can use it to calculate a record-by-record or group-by-group total. You can set it to No, Over Group, or Over All. When it is set to No, no running sum is calculated. When it is set to Over Group, the value of the text box accumulates from record to record within the group but is reset each time the group value changes. An example is a report that shows deposit amounts for each state, with a running sum for the amount deposited within the state. Each time the state changes, the amount deposited is set to zero. When this property is set to Over All, the sum continues to accumulate over the entire report.
The Other properties of a control include properties, such as those described in the following sections, that don't fit into any other category (see Figure 17.10).
The Name property provides an easy and self-documenting way to refer to a control in Visual Basic for Applications (VBA) code and in many other situations. You should name every control so that you can easily identify them in queries, code, and so on.
The Vertical property is used to determine whether the text within a control is displayed vertically. The default value for this property is No.
Like the Tag property of a report, the Tag property of a control provides a user-defined slot for the control. You can place extra information in the Tag property.
A common mistake many Access developers and users make is to give controls names that conflict with Access names. This type of error is very difficult to track down. You need to make sure you use distinctive names for both fields and controls. Furthermore, you should not give a control the same name as a field within its expression. For example, the expression =ContactName & ContactTitle shouldn't have the name "ContactName"; that would cause an #error# message when you run the report. Finally, you shouldn't give a control the same name as its control source. Access gives a bound control the same name as its field, and you need to change this name to avoid problems. Following these simple warnings will spare you a lot of grief!