Microsoft Access 2010 Bible

(Rick Simeone) #1

Part I: Access Building Blocks


266


The Use Control Wizards button, revealed by expanding the Controls group by clicking on the
More button in the lower-right corner of the group, doesn’t add a control to a form. Instead, the
Use Control Wizards button determines whether a wizard is automatically activated when you
add certain controls. The Option Group, Combo Box, List Box, Subform/Subreport, Bound and
Unbound Object Frame, and Command Button controls all have wizards to help you when you
add a new control. You can also use the ActiveX Controls button (also found at the bottom of the
expanded Controls group) to display a list of ActiveX controls, which you can add to Access.

There are three basic categories of controls: bound, unbound, and calculated.

Bound controls
These are controls that are bound to a field in the data source underlying the form. When you
enter a value into a bound control, Access automatically updates the field in the current record.
Most of the controls used for data entry can be bound. Controls can be bound to most data types,
including Text, Date/Time, Number, Yes/No, OLE Object, and Memo fields.

Unbound controls
Unbound controls retain the entered value, but they don’t update any table fields. You can use
these controls for text label display, for controls such as lines and rectangles, or for holding
unbound OLE objects (such as bitmap pictures or your logo) that aren’t stored in a table but on
the form itself. Very often, VBA code is used to work with data in unbound controls and directly
update Access data sources.

Cross-Reference
Turn to Chapters 13 and 19 for details on using VBA control to manipulate forms and controls and working
with unbound data.


Calculated controls
Calculated controls are based on expressions, such as functions or calculations. Calculated controls
are unbound because they don’t directly update table fields. An example of a calculated control is
=[SalePrice] - [Cost]. This control calculates the total of two table fields for display on a
form but is not bound to any table field. The value of an unbound calculated control may be refer-
enced by other controls on the form, or used in an expression in another control on the form or in
VBA in the form’s module.

Adding a control
You add a control to a form in one of three ways:

l (^) By clicking a button in the Design ribbon’s Controls group and drawing a new
unbound control on the form: Use the control’s ControlSource property to bind the
new control to a field in the form’s data source.

Free download pdf