Forms have many properties that you can use
to affect their look and behavior. The properties are broken down into
categories: Format, Data, Event, and Other.
To view a form’s properties, you must first select
the form. To do that, click the form selector (the small gray button at
the intersection of the horizontal and vertical rulers).
It is important that you understand how to work with form properties. The sections that follow begin by focusing on the
Properties window. They then hone in on a discussion of some of the
important form properties.
Working with the Properties Window
After
you have selected a form, you can click the Properties button on the
toolbar to view its properties. The Properties window, shown in Figure 1,
consists of five tabs: Format, Data, Event, Other, and All. Many
developers prefer to view all properties at once on the All tab, but a
form can have a total of 119 properties! Instead of viewing all 119
properties at once, you should try viewing the properties by category.
The Format category includes all the physical attributes of the
form—the ones that affect the form’s appearance, such as background
color. The Data category includes all the properties of the data that
the form is bound to, such as the form’s underlying record source. The
Event category contains all the Windows events to which a form can
respond. For example, you can write code that executes in response to
the form being loaded, becoming active, displaying a different record,
and so on. The Other category holds a few properties that don’t fit
into the other three categories.
Working with the Important Form Properties
As mentioned in the preceding section, a form has
119 properties. Of those 119 properties, 52 are Event properties, and
they are covered in most books focused on Access programming. The
following sections cover the Format, Data, and Other properties of
forms.
The Format Properties of a Form
The
Format properties of a form affect its physical appearance. A form has
39 Format properties. The most important ones are described in the
following sections.
The Caption Property
The Caption property sets the text that appears on the form’s title bar.
The Default View Property
The Default View property allows you to select from five available options:
Single Form— Allows only one record to be viewed at a time
Continuous Forms— Displays as many records as will fit within the form window at one time, presenting each as the detail section of a single form
Datasheet— Displays the records in a spreadsheet-like format, with the rows representing records and the columns representing fields
PivotTable— Displays the records in a Microsoft Excel-type pivot table format
PivotChart— Displays the records in a Microsoft Excel-type pivot chart format
The selected option becomes the default view for the form.
The Scroll Bars Property
The Scroll Bars property determines whether
scrollbars appear if the controls on a form don’t fit within the form’s
display area. You can select from both vertical and horizontal
scrollbars, neither vertical nor horizontal scrollbars, just vertical
scrollbars, or just horizontal scrollbars.
The Record Selectors Property
A record selector is the gray bar to the left of a
record in Form view, or the gray box to the left of each record in
Datasheet view. It’s used to select a record to be copied or deleted.
The Record Selectors property determines whether the record
selectors appear. If you give the user a custom menu, you can opt to
remove the record selector to make sure the user copies or deletes
records using only the features specifically built into the application.
The Navigation Buttons Property
Navigation buttons are the controls that appear at
the bottom of a form; they allow the user to move from record to record
within a form. The Navigation Buttons property determines
whether the navigation buttons are visible. You should set it to No for
any dialog box forms, and you might want to set it to No for data-entry
forms, too, and add your own toolbar or command buttons to enhance or
limit the functionality of the standard buttons. For
example, in a client/server environment, you might not want to give
users the ability to move to the first or last record because that type
of record movement can be inefficient in a client/server architecture.
The Dividing Lines Property
The Dividing Lines property indicates whether you want a line to appear between records when the default view of the form is set to Continuous Forms. It also determines whether Access places dividing lines between the form’s sections (that is, header, detail, and footer).
The Auto Resize Property
The Auto Resize property determines whether Access automatically sizes a form to display a complete record.
The Auto Center Property
The Auto Center property specifies whether a form should automatically be centered within the Application window whenever it’s opened.
The Border Style Property
The Border Style property is far more powerful than its name implies. The options for the Border Style property are None, Thin, Sizable, and Dialog. The Border Style property is often set to None for splash screens, in which case the form has no border. When the Border Style
property is set to Thin, the border is not resizable and the Size
command isn’t available in the Control menu. This setting is a good
choice for pop-up forms, which remain on top even when other forms are
given the focus. The Sizable setting is standard for most forms; it
includes all the standard options in the Control menu. The Dialog
setting creates a border that looks like the border created by the Thin
setting. A form with the Border Style property set to Dialog
can’t be maximized, minimized, or resized; when the border style of a
form is set to Dialog, the Maximize, Minimize, and Resize options
aren’t available in the form’s Control menu. The Dialog setting is
often used along with the Pop Up and Modal properties to create custom dialog boxes.
The Close Button Property
The Close Button property determines
whether the user can close the form by using the Control menu or
double-clicking the Control icon. If you set the value of this property
to No, you must give the user another way to close the form; otherwise,
the user might have to reboot his or her computer to close the
application.
The SubdatasheetHeight Property
The SubdatasheetHeight property is used to designate the maximum height for a sub-datasheet.
The SubdatasheetExpanded Property
The SubdatasheetExpanded property allows
you to designate whether a sub-datasheet is initially displayed in an
expanded format. When this property is set to False, the sub-datasheet
appears collapsed. When it is set to True, the sub-datasheet appears in
expanded format.
The Moveable Property
The Moveable
property determines whether the user can move the form window around
the screen by clicking and dragging the form by its title bar.
The Data Properties of a Form
You use the Data properties of a form to control the
source for the form’s data, what sort of actions the user can take on
the data in the form, and how the data in the form is locked in a
multiuser environment. A form has 14 Data properties (several of which
we cover here).
The Record Source Property
The Record Source property indicates the
table, stored query, or SQL statement on which the form’s records are
based. After you have selected a record source for a form, the controls
on the form can be bound to the fields in the record source.
The Field List window is unavailable until you have set the Record Source property of the form.
|
The Filter Property
You use the Filter property to
automatically load a stored filter along with the form. I prefer to
base a form on a query that limits the data displayed on the form. You
can pass the query parameters at runtime to customize exactly what data
Access displays.
The Order By Property
The Order By property specifies in what order the records on a form appear. You can modify this property at runtime.
The Allow Filters Property
The Allow Filters property controls whether
you can filter records at runtime. When this option is set to No, all
filtering options become disabled to the user.
The Allow Edits, Allow Deletions, and Allow Additions Properties
The Allow Edits, Allow Deletions, and Allow Additions
properties let you specify whether the user can edit data, delete
records, or add records from within a form. These options can’t
override any permissions that you have set for the form’s underlying
table or queries
The Data Entry Property
The Data Entry property determines whether
users can only add records within a form. You should set this property
to Yes if you don’t want users to view or modify existing records but
want them to be able to add new records.
The Other Properties of a Form
Format
properties affect the appearance of a form. Data properties affect the
data underlying a form. This section focuses on the Other properties of
a form. As you’ll see, although these properties don’t fit neatly into
the Format and Data categories, they are extremely robust and powerful
properties. The most commonly used properties are covered here.
Pop Up— The Pop Up property indicates whether a form always remains on top of other windows. You will often set this property, along with the Modal property (discussed next), to Yes when creating custom dialog boxes.
Modal— The Modal property indicates whether the user can remove focus from a form while it’s open. When the Modal
property is set to Yes, the user must close the form before he or she
can continue working with the application. As mentioned earlier, this
property is used with the Pop Up property to create custom dialog boxes.
Cycle— The Cycle
property controls the behavior of the Tab key in a form. The settings
are All Records, Current Record, and Current Page. When you set the Cycle
property to All Records, the user moves to the next record on a form
when he or she presses Tab from the last control on the previous
record. When the property is set to Current Record, the user is moved
from the last control on a form to the first control on the same
record. The Current Page option refers only to multipage forms; when
you set the Cycle property to Current Page, the user tabs
from the last control on the page to the first control on the same
page. All three options are affected by the tab order of the objects on
the form.
Tag— The Tag
property is used to store miscellaneous information about a form. This
property is often set and monitored at runtime to store necessary
information about a form. You could use the Tag property to add a tag to each of several forms that should be unloaded as a group.
Allow Design Changes— The Allow Design Changes
property determines whether changes can be made to the design of a form
while you’re viewing form data. If this property is set to All Views,
the Properties window is available in Form view, and changes made to
form properties while you’re in Form view are permanent if the form is
saved