Setting Form Properties


In addition to the controls on a form, the form itself has a number of properties that you can use to control its appearance and how it works.

Allowing Different Views

When you build a form from scratch (such as the employees form you’ve been working on in this chapter), the Default View property of the form is Single Form. This is the view you’ll see first when you open the form. With the Single Form setting, you can see only one record at a time, and you have to use the Record Number box, the Previous Record and Next Record arrow buttons to the left and right of the Record Number box, or the Go To command in the Find group on the Home tab to move to another record.

If you set the Default View property of the form to Continuous Forms, you can see multiple records on a short form, and you can use the scroll bar on the right side of the form to scroll through the records. If you set the Default View property of the form to Split Form, you can see your employee records in Datasheet view at the top of the Form window. At the bottom of the Form window, you can see one record at a time displayed in the form controls you’ve been designing. Because one record’s data in the tblEmployees table fills your employees form, the Single Form setting is probably the best choice.

Another set of properties lets you control whether a user can change to Form view, Datasheet view, PivotTable view, PivotChart view, or Layout view. These properties are Allow Form View, Allow Datasheet View, Allow PivotTable View, Allow PivotChart View, and Allow Layout View. The default setting for all these properties is No except Form View and Layout View, meaning that a user cannot use the View button on the Ribbon to switch to Datasheet, PivotTable, or PivotChart view. (Users also cannot switch to these views if they right-click the form tab when their Document Windows Options setting is set to Tabbed Documents). If you’re designing a form to be used in an application, you will usually want to eliminate some of the views. For your employees form, set all but the Allow Form View property to No; if you click the arrow in the Views group, the Layout View option should not appear.

Inside Out-Keeping Users Out of Design and Layout Views 

You can make it more difficult to enter Design and Layout views by designing a custom Ribbon for all your forms. See Chapter 24, “The Flnishing Touches,” for details. You can completely prevent a user from opening a form in Design view or switching to Design view only if you give your users an execute-only copy of your application (see Chapter 25, “Distributing Your Application”). You can prevent users from opening a form in Layout view or switching to Layout view by clearing the Enable Layout View For This Database check box in the Current Database category in the Access Options dialog box. This setting affects all forms and reports in your database.

Setting Navigation Options

Because the employees form you’ve been designing displays one record at a time, it is not useful to display the row selector on the left side of the form. You’ve also designed the form to show all the data in a single window, so a scroll bar along the right side of the window isn’t necessary. You also don’t need a horizontal scroll bar. You probably should keep the Record Number box at the bottom of the form, however. To make these changes, set the form’s Record Selectors property on the property sheet to No, the Scroll Bars property to Neither, and the Navigation Buttons property to Yes. Your form should look something like the one shown in Figure 12–48.

image from book
Figure 12–48: The employees form now has views restricted and does not have a record selector or scroll bars.

Defining a Pop-Up and/or Modal Form

You might occasionally want to design a form that stays on top of all other forms even when it doesn’t have the focus. Notice that the undocked property sheet and field list in Design view both have this characteristic. These are called pop-up forms. You can make your employees form a pop-up form by setting the form’s Pop Up property to Yes. Figure 12–49 shows the employees form as a pop-up form on top of the Navigation Pane, which has the focus. Note that the form can “float” on top of other forms or windows, and it can also be moved on top of the Ribbon. A form that isn’t a pop-up form cannot leave the Access workspace below the Ribbon. You might also notice that when you change the employees form’s Pop Up property to Yes, the form no longer has the tab across the top. Even though the Document Windows Options setting is still set to Tabbed Documents for this database, this form now looks like we are using the Overlapping Windows setting.

image from book
Figure 12–49: The employees form as a pop-up form floats on top of the Navigation Pane and the Ribbon.

Caution 

If you play with the frmXmplEmployee5 form to do this, be sure to set the form’s Pop Up property back to No or don’t save your design changes when you close the form.

As you’ll learn in Part 4, “Automating an Access Application,” it’s sometimes useful to create forms that ask the user for information that’s needed in order to perform the next task. Forms have a Modal property that you can set to Yes to “lock” the user into the form when it’s open. The user must make a choice in the form or close the form in order to go on to other tasks. When a modal form is open, you can switch to another application, but you can’t select any other form or Ribbon button in Access until you dismiss the modal form. You’ve probably noticed that most dialog boxes, such as the various wizards in Access, are modal forms. Modal isn’t a good choice for your employees form, but you’ll use the Modal property later to help control application flow.

Controlling Edits, Deletions, Additions, and Filtering

You can set several properties on forms to control whether data in the form can be updated or whether data in the underlying tables can change. You can also prevent or allow user-applied filters on the form. These properties and their settings are shown in Table 12–9.

Table 12–9: Form Properties for Controlling Editing and Filtering
Open table as spreadsheet

Property

Description

Filter

Contains the latest criteria applied as a filter on this form. Forms also have a FilterOn property that you can’t see in the Form window in Design view. When FilterOn is True, the data displayed in the form is filtered by the criteria string found in the Filter property. On a new form, the Filter property is empty.

Filter On Load

You can define criteria in the Filter property and then set Filter On Load to Yes to apply the filter when the form opens. The default setting is No.

Order By

Contains the latest sorting criteria applied to this form. Forms also have an OrderByOn property that you can’t see in the Form window in Design view. When OrderByOn is True, the data displayed in the form is sorted by the criteria string found in the Order By property. On a new form, the Order By property is empty.

Order By On Load

You can define sorting criteria in the Order By property and then set Order By On Load to Yes to apply the sort when the form opens. The default setting is Yes.

Data Entry

Determines whether the form opens a blank record in which you can insert new data. Access won’t retrieve rows from the form’s recordset. The valid settings are Yes and No, and the default setting is No. Setting Data Entry to Yes is effective only when Allow Additions is set to Yes.

Allow Additions

Determines whether a user can add records using this form. The valid settings are Yes and No. The default setting is Yes.

Allow Deletions

Determines whether a user can delete records in this form. The valid settings are Yes and No. The default setting is Yes.

Allow Edits

Determines whether a user can change control values in this form. The valid settings are Yes and No. The default setting is Yes. Note that when you set Allow Edits to No, you cannot change the value of any control on the form, including unbound controls.

Allow Filters

Determines whether a user can see selected records by applying filtering and sorting criteria and whether the user can see all records by clicking the Toggle Filter command in the Sort -& Filter group. If you set the Data Entry property to Yes and set the Allow Filters property to No, the user can only enter new data and cannot change the form to view other existing records. The valid settings for the Allow Filters property are Yes and No. The default setting is Yes.

Defining Window Controls

In some cases, you might want to prevent the user from opening the form’s control menu (clicking the control menu button in the upper-left corner of a window displays a shortcut menu containing the Restore, Move, Size, Minimize, Maximize, Close, and Next commands) or from using the Minimize and Maximize buttons. (This applies only if you have your Document Windows Options setting set to Overlapping Windows. If you have Tabbed Documents selected, you see only a Close button on the right side.) If you want to perform special processing before a form closes (such as clearing the application status before your main switchboard closes), you might want to provide a command button to do the processing and then close the form with a Visual Basic command. (See Part 4 for details about writing a command to close a form.) You can set the form’s Control Box property to No to remove the control menu button from the form window and the Close button from the upper-right corner. This also removes the Minimize and Maximize buttons.

You can set the form’s Close Button property to No to remove the Close button but leave the control menu button (with Close disabled on the control menu). You can set the form’s Min Max Buttons property to Both Enabled, None, Min Enabled, or Max Enabled. If you disable a Minimize or Maximize button, the related command on the form’s control menu becomes disabled.

Caution 

If you are using overlapping windows, you can set a form’s Control Box property to No to remove all control features from the form’s title bar. This means that both the control menu button (which contains the Close command) and the form’s Close button (at the right end of the title bar) will not appear. If you also set the form’s Modal property to Yes, you should always provide an alternative way to close a modal form, such as a command button that executes a macro or Visual Basic command to close the form. Otherwise, the only way to close the form is to use the Windows Ctrl+F4 key combination. See Part 4 for details about writing a command to close a form.

Setting the Border Style

In most cases, you’ll want to create forms with a regular border-one that allows you to size the window and move it around if you have the Document Windows Options setting set to Overlapping Windows. Forms have a Border Style property that lets you define the look of the border and whether the window can be sized or moved. The Border Style property settings are shown in Table 12–10.

Table 12–10: Settings for the Border Style Property
Open table as spreadsheet

Setting

Description

None

The form has no borders, control menu button, title bar, Close button, or Minimize and Maximize buttons. You cannot resize or move the form when it is open. You can select the form and press Ctrl+F4 to close it unless the form’s Pop Up property is set to Yes. You should write Visual Basic code to provide an alternative way to close this type of form.

Thin

The form has a thin border, signifying that the form cannot be resized.

Sizable

This is the default setting. The form can be resized.

Dialog

If the Pop Up property is set to Yes, the form’s border is a thick line (like that of a true Windows dialog box), signifying that the form cannot be resized. If the Pop Up property is set to No, the Dialog setting is the same as the Thin setting.

Understanding Other Form Properties

Table 12–11 describes form settings not yet discussed and explains their usage. The table lists the properties in the sequence you will find them on the All tab in the property sheet.

Table 12–11: Other Form Properties
Open table as spreadsheet

Property

Description

Display On SharePoint Site

The default setting, Do Not Display, specifies that if this database is upsized to a Microsoft Windows SharePoint Services (version 3) site, Access will not create a view on the Windows SharePoint Services Version 3 site of this form. The Follow Table Setting option causes Access to honor the setting specified for the underlying table.

Picture

Enter the path and file name of a graphic file to use as the background of the form. You can click the Build button next to the property to locate the picture you want. You might find this useful to display an image such as a company logo on the background of your forms.

Picture Tiling

The default setting, No, places one copy of the picture on the form. Choose Yes if you want multiple copies “tiled” on the form. When you choose Yes, you must set Picture Alignment to Clip or Zoom, and the picture should be smaller than the form design or form window. Setting Picture Tiling to Yes is useful if your picture is a small pattern bitmap.

Picture Alignment

This property applies only when Picture Size Mode is Clip or Zoom. The default setting, Center, centers the picture in the form window area. Form Center centers the picture in the form design area. You can also specify that the picture align in the top left, top right, bottom left, or bottom right of the form.

Picture Type

Choose Embedded (the default) to store a copy of the picture in your form design. Use Linked to save space in your database, but the form must then always load the picture from the specified picture path when it opens; and if you move the picture to a different location, it might not display.

Picture Size Mode

Clip (the default) specifies that the picture appears in its original resolution. If the form is larger than the picture, the picture will not cover the entire form area. If the form is smaller than the picture, you’ll see only part of the picture. Use Stretch to stretch the picture to the dimensions of the form, but the picture might appear distorted. Use Zoom to stretch the picture to the dimensions of the form without distorting it; but if the aspect ratio of the picture does not match the display space of the form, the picture won’t cover the entire form background.

Width

Specifies the width of the form in inches or centimeters. Access automatically updates this property when you drag the right edge of the design area wider or narrower in Design view or Layout view. You cannot set this property to nothing (blank).

Auto Center

Choose No (the default) to open the form on the screen wherever it was placed when you last saved its definition from Design view, Layout view, or Form view. Choose Yes to automatically center the form in the Access workspace when you open it. This applies only if you are using a multiple-document interface.

Auto Resize

The default Yes setting automatically resizes the form window to its design height and width when you open the form. Choose No if you want to set a specific window size. This applies only if you are using a multiple-document interface.

Fit To Screen

The default setting, No, tells Access not to reduce the width of the form if the form window size is reduced. Choose Yes if you want Access to automatically reduce the width of the form to fit within the available screen space. This applies only if you are using a multiple-document interface.

Navigation Caption

You can use this property to set descriptive text to be used to the left of the form’s navigation buttons. If left blank, Access uses the word Record.

Dividing Lines

When you design your form with a Header or a Footer section, Yes (the default) specifies that you will see a horizontal line separating each section. No removes the line(s).

Moveable

The default setting, Yes, allows the user to move the form in the Access window if using a multiple-document interface. Set this property to No to lock the form on the screen where you last saved it.

Split Form Size

You can use this setting to adjust the size of the form and datasheet if the form is displayed in Split Form view. If you use a larger setting here, Access displays more of the form and less of the datasheet. The default setting, Auto, tells Access to reset the form and datasheet size.

Split Form Orientation

The default setting, Datasheet On Top, displays the datasheet portion of a form in Split Form view at the top of the form window. You can also choose to display the datasheet potion in different positions using the other three options-Datasheet On Bottom, Datasheet On Left, or Datasheet On Right

Split Form Splitter Bar

The default setting, Yes, displays a separator bar between the form and datasheet potions of a form in Split Form view. Choose No to hide the separator bar. When the splitter bar is hidden, the user cannot change the size of the two portions.

Split Form Datasheet

The default setting, Allow Edits, allows you to make changes to the data in the datasheet potion of a form in Split Form view. Choose Read Only to disallow any edits of the data in the datasheet portion.

Split Form Printing

The default setting, Form Only, specifies that Access prints only the form portion of a form in Split Form view if the user decides to print the form. Choose Datasheet Only to have Access print only the contents of the datasheet portion.

Save Splitter Bar Position

The default setting, Yes, specifies that Access attempts to save the splitter bar position when you close a form in Split Form view. You can move the splitter bar to display more or less of either the form or datasheet portion of the form, but you cannot do this when the Split Form Splitter Bar property is set to No. If this property is set to Yes when you close the form, Access prompts you to save the changes to the form. If you choose No, Access does not save the new location. Set this property to No to discard any changes to the splitter bar location upon closing the form.

Subdatasheet Expanded and Subdatasheet Height

These properties are identical to those that you can define for tables and queries. Your form must be in Datasheet view and must have a subform that is also in Datasheet view. See Chapter 13 for details.

Layout for Print

The default setting, No, indicates that printer fonts installed on your computer will not be available in any font property settings, but screen fonts and TrueType fonts will be available. Choosing Yes disables screen fonts but makes printer fonts and TrueType fonts available.

Orientation

The default in most versions of Access 2007 is Left-to-Right. In versions that support a language that is normally read right to left, the default is Right-to-Left. When you use Right-to-Left, captions appear right-justified, the order of characters in controls is right to left, and the tab sequence proceeds right to left.

Recordset Type

The default setting, Dynaset, specifies that all controls bound to fields in the record source will be updatable as long as the underlying field would also be updatable. If your form is bound to a query, see “Limitations on Using Select Queries to Update Data” on page 468. Dynaset (Inconsistent Updates) specifies that all fields (other than fields resulting from expressions or AutoNumber fields) can be updated, even if the update would break a link between related tables. (We do not recommend this option because it can allow a user to attempt to make a change that would violate integrity rules.) Snapshot specifies that the data is read-only and cannot be updated.

Fetch Defaults

Choose Yes (the default) to have the form fetch the default values from the field definitions when you move to a new row. Set this property to No to use only the Default Value settings you have specified for controls.

On Current through Before Screen Tip

You can set these properties to run a macro, a function, or an event procedure when the specific event described by the property occurs for this form. See Part 4 for details.

Cycle

Use the default setting, All Records, to tab to the next record when you press the Tab key in the last control in the tab order. Choose Current Record to disallow tabbing from one record to another. Choose Current Page on a multipage form to disallow tabbing onto the next or previous page-you must use Page Up or Page Down to move between pages. When you set Current Record or Current Page, you must use the navigation buttons or Ribbon commands to move to other records.

Record Locks

No Locks (the default) specifies that Access will not lock any edited row until it needs to write the row back to the table. This is the most efficient choice for most applications. Edited Record specifies that Access apply a lock to the row the instant you begin typing in the record. This can lock out other users in a shared environment. All Records (not recommended) locks every record in the record source as soon as you open the form.

Ribbon Name

You can design a custom Ribbon to display for your forms and reports, and you can enter the name of your custom Ribbon in this property. See Chapter 24 for more details.

Toolbar, Menu Bar, and Shortcut Menu Bar

Using Access 2000, 2002, or 2003 in an MDB format database, you can design a custom menu bar, toolbar, and shortcut menu for your forms and reports, and you enter the name of your custom menus or toolbars in these properties. These properties are supported in Access 2007 for backward compatibility with earlier versions.

Shortcut Menu

The default setting, Yes, indicates shortcut menus will be available for the form and all controls on the form. Choose No to disable shortcut menus.

Help File

When you create a custom help file for your application, enter the path and file name in this property. See Chapter 24 for details.

Help Context ID

You can create a custom help file for your application and identify specific topics with a context ID. If you want a particular topic to appear when a user presses F1 when using this form, enter the ID of the topic in this property. If the focus is in a control that also has a Help Context ID property defined, the topic for that control is displayed. See Chapter 24 for details.

Has Module

If you create Visual Basic event procedures for this form, Access automatically sets this property to Yes. If you change this property from Yes to No, Access warns you that doing so will delete all your code and gives you a chance to cancel the change. See Part 4 for details.

Fast Laser Printing

The default setting, Yes, specifies that Access will use laser printer line fonts to draw lines and rectangles if you print the form on a printer that supports this option. Choose No to send all lines to your printer as graphics.

Tag

You can use this property to store additional descriptive information about the form. You can write Visual Basic code to examine and set this property or take a specific action based on the property setting. The user cannot see the contents of the Tag property.

Palette Source

Enter the name of a graphic file or Windows palette file that provides a color palette to display this form. You might need to set this property if you have also set the Picture property so that the colors of the background picture display properly. The default setting, (Default), uses your current Windows palette.




Microsoft Office Access 2007 Inside Out
MicrosoftВ® Office Access(TM) 2007 Inside Out (Microsoft Office Access Inside Out)
ISBN: 0735623252
EAN: 2147483647
Year: 2007
Pages: 234

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net