What Control Properties Are Available, and Why Should You Use Them?
Available Control properties vary quite a bit, depending on the type of control that's been selected. The more common properties are covered in this section; individual properties are covered throughout the book as they apply to a specific topic.
Format Properties of a Control
The Format properties of a control affect the visual appearance of the control. They include the following:
- Format
The Format property of a control determines how the data in the control is displayed. A control's format is automatically inherited from its underlying data source. This property is used in three situations:- When the Format property is not set for the underlying field
- When you want to override the existing Format setting for the field
- When you want to apply a format to an unbound control
- Decimal Places
Specifies how many decimal places you want to appear in the control. This property is used with the Format property to determine the control's appearance. - Caption
You use the Caption property to specify information helpful to the user. It's available for labels, command buttons, and toggle buttons. - Hyperlink Address
The Hyperlink Address property is available only for command buttons, images, and unattached labels. It contains a string used to specify the UNC (path to a file) or URL (Web page address) associated with the control. When the form is active and the cursor is placed over the control, clicking the control displays the specified object or Web page. - Hyperlink SubAddress
Like the Hyperlink Address property, the Hyperlink SubAddress property is available only for command buttons, images, and unattached labels. The Hyperlink SubAddress property is a string representing a location in the document specified in the Hyperlink Address property. - Visible
Indicates whether a control is visible. This property can be toggled at runtime, depending on specific circumstances. For example, a question on the form might apply only to records in which the gender is set to Female; if the gender is set to Male, the question shouldn't be visible. - Display When
Used when you want certain controls on the form to be sent only to the screen or only to the printer. The three options are Always, Print Only, or Screen Only. An example of the use of the Display When property is a label containing instructions. You might want the instructions to appear on the screen but not on the printout. - Scroll Bars
Determines whether scrollbars appear when the data in the control doesn't fit within the control's size. The options are None and Vertical. I often set the Scroll Bars property to Vertical when the control is used to display data from a Memo field. The scrollbar makes it easier for the user to work with a potentially large volume of data in the Memo field. - Can Grow, Can Shrink
The Can Grow and Can Shrink properties apply only to the form's printed version. The Can Grow property, when set to Yes, expands the control when printing so that all the data in the control fits on the printout. When you set the Can Shrink property to Yes and no data has been entered, the control shrinks so that blank lines won't be printed. - Left, Top, Width, Height
You use these properties to set the control's position and size. - Back Style, Back Color
You can set the Back Style property to Normal or Transparent. When set to Transparent, the form's background color shows through the control. This is often the preferred setting for an option group. The control's Back Color property specifies the background color (as opposed to text color) for the control.CAUTIONIf the Back Style of a control is set to Transparent, the control's back color is ignored. - Special Effect
Adds 3D effects to a control. The options for this property are Flat, Raised, Sunken, Etched, Shadowed, and Chiseled. Each of these effects gives the control a different look. - Border Style, Border Color, Border Width
These properties affect the look, color, and thickness of a control's border. The border style options are Transparent, Solid, Dashes, Short Dashes, Dots, Sparse Dots, Dash Dot, and Dash Dot Dot. The Border Color property specifies the color of the border; you can select from a variety of colors. The Border Width property can be set to one of several point sizes.CAUTIONIf the Border Style of a control is set to Transparent, the control's Border Color and Border Width are ignored. - Fore Color, Font Name, Font Size, Font Weight, Font Italic, Font Underline
These properties control the appearance of the text in a control. As their names imply, they let you select the color, font, size, and thickness of the text and determine whether the text is italicized or underlined. These properties can be modified in response to a runtime event, such as modifying a control's text color if the value in that control exceeds a certain amount. The Font Weight selections generally exceed what is actually available for a particular font and printernormally, you have a choice of only Regular and Bold in whatever value you select for this property. - Text Align
The Text Align property is often confused with the capability to align controls. The Text Align property affects how the data is aligned within a control. - Reading Order
The Reading Order property was introduced with Access 2002. As its name implies, it allows you to specify the reading order for text in a control. This feature is available only if you are using a version of Microsoft Office that supports right-to-left features. - Keyboard Language
The Keyboard Language property was introduced with Access 2002. It allows you to override the keyboard language currently in use. This means that when a specific control receives the focus, the language specified in this property becomes the keyboard language in effect while typing data into the control. - Scroll Bar Align
The Scroll Bar Align property is another language-related property introduced with Access 2002. You use this property to place the vertical scrollbars in the appropriate left-to-right or right-to-left position. If you select the System option, the position of the scrollbar is based on the selected user interface language. The scrollbar is placed on the right for left-to-right languages and on the left for right-to-left languages. If you select Left or Right, the scrollbar is placed on the left or right side of the control, respectively. - Numerical Shape
The Numerical Shape property was introduced with Access 2002. It allows you to designate whether numeric shapes are displayed in the Arabic or Hindi style. The available choices for this property are System, Arabic, National, and Context. System bases the Numerical Shape on the operating system. Arabic and National use the Arabic and Hindi styles, respectively. Context bases the numerical style on the text adjacent to the control. - Left Margin, Top Margin, Right Margin, Bottom Margin
These properties determine how far the text appears from the left, top, right, and bottom of the control. They are particularly useful with controls such as text boxes based on memo fields, which are generally large controls. - Line Spacing
Used to determine the spacing between lines of text in a multi-line control. This property is most commonly used with a text box based on a memo field. - Is Hyperlink
This property, when set to Yes, formats the data in the control as a hyperlink. If the data in the control is a relevant link (that is, http:\\microsoft.com), the data will function as a hyperlink.
Data Properties of a Control
The Data properties of a control all have to do with the data underlying the control. They include the following:
- Control Source
Specifies the field from the record source that's associated with a particular control. A control source can also be any valid Access expression. - Input Mask
The Format and Decimal Places properties affect the appearance of a control, but the Input Mask property affects what data can be entered into the control. The input mask of the field underlying the control is automatically inherited into the control. If no input mask is entered as a field property, the input mask can be entered directly in the form. If the input mask of the field is entered, the input mask of the associated control on a form can be used to further restrict what is entered into that field via the form.NOTEIf a control's Format property and Input Mask property are different, the Format property affects the display of the data in the control until the control gets focus. After the control gets focus, the Input Mask property prevails. - Default Value
Determines the value assigned to new records entered in the form. You can set this property within the field properties. A default value set at the field level is automatically inherited into the form. The default value set for the control overrides the default value set at the field level. - Validation Rule, Validation Text
The validation rule and validation text of a control perform the same functions as they do for a field.CAUTIONBecause the validation rule is enforced at the database engine level, the validation rule set for a control can't be in conflict with the validation rule set for the field to which the control is bound. If the two rules conflict, the user can't enter data into the control. - Enabled
Determines whether you allow a control to get focus. If set to No, the control appears dimmed. - Locked
Determines whether the user can modify the data in the control. When the Locked property is set to Yes, the control can get focus but can't be edited. The Enabled and Locked properties of a control interact with one another. Table 5.1 summarizes their interactions.Table 5.1. How the Enabled and Locked Properties Interact
Enabled Locked Effect Yes Yes The control can get focus; its data can be copied but not modified. Yes No The control can get focus, and its data can be edited. No Yes The control can't get focus. No No The control can't get focus; its data appears dimmed. - Filter Lookup
Indicates whether you want the values associated with a bound text box to appear in the Filter By Form window.
Other Properties of a Control
The Other properties of a control are properties that do not fit neatly into any other category. They include the following:
- Name
Allows you to name the control. This name is used when you refer to the control in code and is also displayed in various drop-down lists that show all the controls on a form. It's important to name your controls because named controls improve your code's readability and make working with Access forms and other objects easier. The naming conventions for controls are in Appendix B, "Naming Conventions." - IME Hold, IME Mode, IME Sentence Mode
The IME (Input Method Editor) properties were introduced with Access 2002. IME is a program that converts keystrokes into East Asian character sets. The IME properties are used to designate the settings in effect when an Input Method Editor is used. - Status Bar Text
Specifies the text that appears in the status bar when the control gets focus. This property setting overrides the Description property that can be set in a table's design. - Enter Key Behavior
Determines whether the Enter key causes the cursor to move to the next control, or adds a new line in the current control. This setting is often changed for text boxes used to display the contents of Memo fields. - Allow AutoCorrect
Specifies whether the AutoCorrect feature is available in the control. The AutoCorrect feature automatically corrects common spelling errors and typos. - Vertical
Used to control whether the text in the control is displayed horizontally or vertically. The default is No, or horizontal. When Yes (vertical display) is selected, the text within the control is rotated 90 degrees. - Auto Tab
The Auto Tab property, when set to Yes, automatically advances the cursor to the next control when the last character of an input mask has been entered. Some users like this option, and others find it annoying, especially if they must tab out of some fields but not others. - Default
Applies to a command button or ActiveX control and specifies whether the control is the default button on a form. - Cancel
Applies to a command button or ActiveX control. It indicates that you want the control's code to execute when the Esc key is pressed while the form is active. - Auto Repeat
Specifies whether you want an event procedure or macro to execute repeatedly while its command button is being pressed. - Tab Stop
Determines whether the Tab key can be used to enter a control. It's appropriate to set this property to No for controls whose values rarely get modified. The user can always opt to click in the control when necessary. - Tab Index
Sets the tab order for the control. I generally set the Tab Index property by using View, Tab Order, rather than by setting the value directly in the control's Tab Index property. - Shortcut Menu Bar
The Shortcut Menu Bar property attaches a specific menu to a control. The menu bar appears when the user right-clicks the control. - ControlTip Text
Specifies the ToolTip associated with a control. The ToolTip automatically appears when the user places the mouse pointer over the control and leaves it there for a moment. - Help Context ID
Designates the Help topic associated with a particular control. - Tag
An extra property you can use to store information about a control. Your imagination determines how you use this property. The Tag property can be read and modified at runtime.