[ Team LiB ] Previous Section Next Section

What Form Properties Are Available, and Why Should You Use Them?

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 select the form in one of two ways:

  • Click the form selector (the small gray button at the intersection of the horizontal and vertical rulers).

  • Choose Edit | Select Form.

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 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 11.28, 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 107 properties! Rather than view all 107 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.

Figure 11.28. Viewing the Format properties of a form.

graphics/11fig28.jpg

Working with the Important Form Properties

As mentioned in the preceding section, a form has 107 properties. Of those 107 properties, 52 are Event properties, and they are covered in most books focused on Access programming. The following sections and Hour 16, "Power Form Techniques," 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 31 Format properties, described in the following sections.

Caption

The Caption property sets the text that appears on the form's title bar.

Default View

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 PivotTable format.

  • PivotChart— Displays the records in a Microsoft Excel–type PivotChart format.

The selected option becomes the default view for the form.

Allow Form View

In versions of Access prior to Access 2002, Access forms have a property called Views Allowed. The Views Allowed property determines whether the user is allowed to switch from Form view to Datasheet view or vice versa. Whereas the Default View property determines the initial default display mode for the form, Views Allowed determines whether the user is permitted to switch out of the default view.

In Access 2002 and Access 2003, Microsoft has separated out each type of view as an additional property for the form. The Allow Form View property specifies whether the user is permitted to switch to the Form view of a form.

Allow Datasheet View

The Allow Datasheet View property determines whether the user is permitted to switch to the Datasheet view of a form.

Allow PivotTable View

The PivotTable View property determines whether the user is allowed to switch to the PivotTable view of a form.

Allow PivotChart View

The Allow PivotChart View property determines whether the user is allowed to switch to the PivotChart view of a form.

Scroll Bars

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.

Record Selectors

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.

Navigation Buttons

Navigation buttons are the controls that appear at the bottom of aform; 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 dataentry 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.

Dividing Lines

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).

Auto Resize

The Auto Resize property determines whether Access automatically sizes a form to display a complete record.

Auto Center

The Auto Center property specifies whether a form should automatically be centered within the Application window whenever it's opened.

Border Style

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 along with the Pop Up and Modal properties to create custom dialog boxes.

Control Box

The Control Box property determines whether a form has a Control menu. You should use this option sparingly. One of your responsibilities as a developer of Access applications is to make applications comply with Windows standards. If you look at the Windows programs you use, you'll find very few forms that do not have Control menu boxes. This should tell you something about how to design applications.

Min Max Buttons

The Min Max Buttons property indicates whether the form has minimize and maximize buttons. The available options are None, Min Enabled, Max Enabled, and Both Enabled. If you remove one or both of these buttons, the appropriate options also become unavailable in the Control menu. Access ignores the Min Max property for forms with the Border Style property set to None or Dialog. Similarly to the Control Box property, I rarely use this property. To make applications comply with Windows standards, I set the Border Style property and then inherit the standard attributes for each border style.

Close Button

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.

Whats This Button

The Whats This Button property specifies whether you want the Whats This button to be added to the form's title bar. This feature works only when the form's Min Max Buttons property is set to No. When the Whats This Button property is set to Yes, the user can click the Whats This button and then click an object on the form to display Help for that object. If the selected object has no Help associated with it, Help for the form is displayed, and if the form has no Help associated with it, the Microsoft Access Help system is displayed.

Width

The Width property is used to specify the form's width. This option is most often set graphically by clicking and dragging to select an appropriate size for the form. You might want to set this property manually when you want forms to be exactly the same size.

Picture, Picture Type, Picture Size Mode, Picture Alignment, and Picture Tiling

The Picture, Picture Type, Picture Size Mode, Picture Alignment, and Picture Tiling properties let you select and customize the attributes of a bitmap used as the background for a form.

Grid X and Grid Y

You can use the Grid X and Grid Y properties to modify the spacing of the horizontal and vertical lines that appear in a form in Design view. By setting these properties, you can affect how precisely you place objects on the form when the Snap to Grid feature is active.

Layout for Print

The Layout for Print property specifies whether screen or printer fonts are used on a form. If you want to optimize a form for printing rather than display, you should set this property to Yes.

SubdatasheetHeight

The SubdatasheetHeight property is used to designate the maximum height for a subdatasheet.

SubdatasheetExpanded

The SubdatasheetExpanded property allows you to designate whether a subdatasheet is initially displayed in an expanded format. When this property is set to False, the subdatasheet appears collapsed. When it is set to True, the subdatasheet appears in expanded format.

Palette Source

The Palette Source property determines the source for selecting colors for a form.

Orientation

The Orientation property allows you to take advantage of language-specific versions of Microsoft Access, such as Arabic. This property can be set to support right-to-left display features for language-specific editions of Access, provided that the underlying operating system supports that language and is 32 bit (for example, Windows 2000).

Moveable

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 11 Data properties (8 which are covered here).

Record Source

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.

graphics/book_icon.gif

The Field List window is unavailable until you have set the Record Source property of the form.


Filter

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.

Order By

The Order By property specifies in what order the records on a form appear. You can modify this property at runtime.

Allow Filters

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.

Allow Edits, Allow Deletions, and Allow Additions

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. Hour 22, "Security Introduced," covers the basics of security.

Data Entry

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.

More About Form and Control Properties

Additional interesting form properties, as well as control properties, help you to further customize forms and the controls that you place on them. Hour 16 further delves into form properties and explores the exciting world of control properties.

    [ Team LiB ] Previous Section Next Section