Understanding Properties

Properties are named attributes of controls, fields, or database objects that are used to modify the characteristics of a control, field, or object. Examples of these attributes are the size, color, appearance, or name of an object. A property can also modify the behavior of a control, determining, for example, whether the control is read-only or editable and visible or not visible.

Properties are used extensively in forms and reports to change the characteristics of controls. Each control on the form has properties. The form itself also has properties, as does each of its sections. The same is true for reports; the report itself has properties, as does each report section and individual control. The label control also has its own properties, even if it is attached to another control.

Everything from moving and resizing controls to changing fonts and colors that you do with the Ribbon commands can be done by setting properties. In fact, all these commands do is change properties of the selected controls.

Displaying the Property Sheet

Properties are displayed in a Property Sheet (sometimes called a Property window). To display the Property Sheet for the Description text box, follow the steps below. You will be creating a new blank form.

1.
Drag the first five fields, ProductID through Cost , from the Field List window to the form’s Design View.

2.
Click the Description text box control to select it.

3.
Click the Property Sheet command in the Design tab’s Tools group to display the Property Sheet—which appears docked to the right side of the Access window, taking the place of the Field List.

The screen should look like the one shown in Figure 35-20.

Figure 35-20. Change an object’s properties with the Property Sheet.


Because the Property Sheet is a window, it can be undocked, moved, and resized. It does not, however, have Maximize or Minimize buttons. There are several ways to display a control’s Property Sheet if it’s not visible:

  • Select a control and click the Property Sheet command in the Design tab’s Tools group.

  • Double-click any control.

  • Right-click any control and select Properties from the pop-up menu.

Understanding the Property Sheet

With the Property Sheet displayed, click on any control in Design View to display the properties for that control. Select multiple controls to display similar properties for the selected controls.

In Figure 35-20, the Property Sheet has been sized to fit the screen. By widening the Property Sheet, you can see more of its values; by increasing the length, you can see more controls at one time. The vertical scroll bar lets you move between various properties.

The Property Sheet has an All tab that lets you see all the properties for a control. Or you can choose another tab to limit the view to a specific group of properties. The specific tabs and groups of properties are as follows:

  • Format: These properties determine how a label or value looks: font, size, color, special effects, borders, and scroll bars.

  • Data: These properties affect how a value is displayed and the data source it is bound to: control source, input masks, validation, default value, and other data type properties.

  • Event: Event properties are named events, such as clicking a mouse button, adding a record, pressing a key for which you can define a response (in the form of a call to a macro or a VBA procedure), and so on.

  • Other: Other properties show additional characteristics of the control, such as the name of the control or the description that displays in the status bar.

Figure 35-20 shows the Property Sheet for the Description text box. The first column lists the property names; the second column is where you enter or select property settings or options.

Changing a control’s property setting

There are many different methods for changing property settings, including the following:

  • Entering or selecting the desired value in a Property window

  • Changing a property directly by changing the control itself, such as changing its size

  • Using inherited properties from the bound field or the control’s default properties

  • Entering color selections for the control by using the Ribbon commands

  • Changing label text style, size, color, and alignment by using the Ribbon commands

You can change a control’s properties by clicking a property and typing the desired value.

In Figure 35-21, you can see a down arrow and a button with three dots to the right of the Control Source property-entry area. Some properties display a drop-down arrow in the property-entry area when you click in the area. The drop-down arrow tells you that Access has a list of values from which you can choose. If you click the down arrow in the Control Source property, you find that the drop-down list displays a list of all fields in the data source—tblProducts. Setting the Control Source property to a field in a table creates a bound control.

Figure 35-21. The Property Sheet undocked


Some properties have a list of standard values such as Yes or No; others display varying lists of fields, forms, reports, or macros. The properties of each object are determined by the object itself and what the object is used for.

A nice feature in Access 2007 is the capability to cycle through property choices by repeatedly double-clicking on the choice. For example, double-clicking on the Display When property alternately selects Always, Print Only, and Screen Only.

The Builder button contains an ellipsis (three dots) and opens one of the many builders in Access—including the Macro Builder, the Expression Builder, and the Module Builder. When you open a builder and make some selections, the property is filled in for you.

Each type of object has its own property window and properties. These include the form itself, each of the form sections, and each of the form’s controls. You display each of the property windows by clicking on the object first. The property window will instantly change to show the properties for the selected object.

Naming control labels and their captions

You might notice that each of the data fields has a Label control and a Text Box control. Normally, the label’s Caption property is the same as the text box’s Name property. The text box’s Name property is usually the same as the table’s field name—shown in the Control Source property. Sometimes, the label’s Caption is different because a value was entered into the Caption property for each field in the table.

When creating controls on a form, it’s a good idea to use standard naming conventions when setting the control’s Name property. Name each control with a prefix followed by a meaningful name that you’ll recognize later (for example, txtTotalCost, cboState, lblTitle). Table 35-2 shows the naming conventions for form and report controls. You can find a very complete, well-established naming convention online by searching for “Reddick Naming Convention.”

Table 35-2. Form/Report Control Naming Conventions
PrefixObject
frbBound Object frame
chtChart (Graph)
chkCheck Box
cboCombo Box
cmdCommand Button
ocxActiveX Custom Control
detDetail (section)
gft[n]Footer (group section)
fftForm Footer section
fhdForm Header section
ghd[n]Header (group section)
hlkHyperlink
imgImage
lblLabel
linLine
lstList Box
optOption Button
grpOption Group
pgePage (tab)
brkPage break
pftPage Footer (section)
phdPage Header (section)
shpRectangle
rftReport Footer (section)
rhdReport Header (section)
secSection
subSubform/Subreport
tabTab Control
txtText Box
tglToggle Button
fruUnbound Object Frame

The properties displayed in Figure 35-21 are the specific properties for the Description text box. The first two properties, Name and Control Source, are set to Description.

The Name is simply the name of the field itself. When a control is bound to a field, Access automatically assigns the Name property to the bound field’s name. Unbound controls are given names such as Field11 or Button13. However, you can give the control any name you want.

With bound controls, the Control Source property is the name of the table field to which the control is bound. In this example, Description refers to the field with the same name in tblProducts. An unbound control has no control source, whereas the control source of a calculated control is the actual expression for the calculation, as in the example =[SalePrice] - [Cost].

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset