Setting Form Properties

Like just about everything else in Access, forms have properties. The properties of a form control some of its behavior, as well as its look and feel. For example, you can use form properties to prevent data from being accidentally deleted or to change the color of a form from gray to lime green. In this section, you'll learn about two ways to set the properties of your forms. For a quick facelift, you can use the AutoFormat function. On the other hand, for complete control over all aspects of your forms, you can use the Properties window.

Note

graphics/note.gif

You can download the Chapter 13.mdb sample file for this chapter from http://www.quepublishing.com/. If you want to follow along with our examples, download Chapter 12.mdb .


Using AutoFormat

AutoFormat in Access provides an easy way to change the overall appearance of a form. Although this tool is easy to use, it requires you to work with your form in design view. That's nothing to be scared ofwe're going to work almost exclusively with design view in this chapterbut you need to be careful. In design view, however, you can change any aspect of a form, including things (such as its connection to the underlying data) that you might not want to alter.

Tip

graphics/tip.gif

If you make a mistake in design view (such as deleting a control you meant to keep), just close the form and click No when Access asks if you want to save changes.


Here's how you can use AutoFormat to dress up the Catalogs form:

  1. Select the Forms shortcut in the Database window.

  2. Select the Catalogs form.

  3. Click the Design button on the Database Window toolbar to open the form in design view.

  4. Select Format , AutoFormat , or click the AutoFormat button on the toolbar. Either way, the AutoFormat dialog box will open, as shown in Figure 13.1. Notice that the Standard option is the default format; this feature defaults to the format last used, so don't worry if your system chooses a different option.

    Figure 13.1. The AutoFormat dialog box.

    graphics/13fig01.gif

  5. The list at the left side of the AutoFormat dialog box includes all the available AutoFormats. As you click each one, the center section of the dialog box changes to show you a preview of the format. Select the Blends AutoFormat.

  6. Click OK to apply the AutoFormat.

  7. Select View , Form View to see the form with the selected AutoFormat applied, as shown in Figure 13.2.

    Figure 13.2. In just a few quick steps, you applied the Blends AutoFormat to this form.

    graphics/13fig02.jpg

  8. Click the Save button on the toolbar to save the changes to the form. Close the form when you're done inspecting the results.

Applying an AutoFormat to a form doesn't affect any of the form's functions. Instead, it makes changes to the form's appearance. In particular, it can change the font used for labels and text, the color used for controls, the image used for the form's background, and the borders used around controls.

You can do two other things in the AutoFormat dialog box. First, if you click Options, you can selectively choose whether to apply the AutoFormat to fonts, colors, and borders or to leave them alone. Second, you can click Customize to modify the available AutoFormats as follows :

  • You can create a new AutoFormat based on the contents of the current form.

  • You can change the selected AutoFormat to match the current form (instead of changing the form to match the AutoFormat).

  • You can delete an AutoFormat entirely.

When you come up with a look that you particularly like for a database, you can use the AutoFormat options to turn this look into a new AutoFormat. Then, you can apply that AutoFormat to the other forms in your database, allowing you to easily create a consistent user interface. You'll learn more about customizing AutoFormats in Chapter 14, "Dressing Up Your Reports."

Note

graphics/note.gif

AutoFormats are stored in Access itself, not in individual databases. So, if you create a new AutoFormat in one database, you can use it in all your databases.


Using the Properties Window

You'll recall from previous chapters that properties are the values that describe a particular object. Similar to other objects in Access, forms have a set of properties that control their appearances and behaviors. To change the properties of a form, you can use the Properties window. Here's an example:

  1. Open the Plants form in form view. You'll see the first record in the Plants table displayed on the form.

  2. Do one of the following: select View , Properties ; press F4 ; or click the Properties toolbar button (as usual, Access provides more than one way to do things). This opens the Properties window, as shown in Figure 13.3, which displays the properties of the control that has the focus (in this case, the CommonName text box).

    Figure 13.3. Viewing the Properties window.

    graphics/13fig03.jpg

  3. Click twiceslowly (don't double-click)in the gray area between the controls on the form. The Properties window changes to show the properties of the form itself.

  4. Click the Format tab in the Properties window.

  5. Scroll down the list of properties to locate the Picture property, which is currently set to (None). Click in this property to reveal a build button.

  6. Click the build button to open the Insert Picture dialog box. Browse to the Windows directory on your computer, and select the Feather Texture.bmp file. Click OK .

  7. Select the Picture Tiling property and change its value from No to Yes . Figure 13.4 shows the resulting form.

    Figure 13.4. A form with new properties.

    graphics/13fig04.gif

  8. Close the Properties window and save the form.

Unlike AutoFormat, you can use the Properties window no matter which view you're using to display a formeither design view or form view. As you saw in this example, changes made through the Properties window take effect immediately. The changes aren't permanent, though, unless you save the form after making the changes.

What can you change with the Properties window? Anything! Well, just about. In fact, if you look at the properties that appear for the form, you'll find an almost frightening array of properties. Fortunately, you won't need to use most of these.

Five tabs appear at the top of the Properties window. As you click these tabs, the window displays different sets of properties. These tabs are as follows:

  • Format Properties that control the appearance of the selected item

  • Data Properties that control the data displayed by the selected item

  • Event Properties that control the code executed by the selected item

  • Other Properties that don't fit into one of the three previous classes

  • All All the properties of the item in one big list

We won't discuss event properties in this chapter; you'll learn a bit about them in Chapter 15, "Automating Your Database." In this chapter, you'll work only with properties from the Format, Data, and Other categories.

Table 13.1 lists some of the properties of the form that you might find useful.

Table 13.1. Properties of an Access Form

Property

Meaning

Record Source

The table or query from which the form gets its data

Caption

The text displayed at the top of the form

Allow Edits

Controls whether the form can be used to edit data

Allow Deletions

Controls whether the form can be used to delete data

Allow Additions

Controls whether the form can be used to add data

Scroll Bars

Controls whether scrollbars appear on the form

Record Selectors

Controls whether record selectors (the bars to the left of the data) appear on the form

Navigation Buttons

Controls whether the navigation bar appears at the bottom of the form

Dividing Lines

Controls whether lines appear between the records when the form is displayed in continuous forms view, as well as whether lines appear between sections of the form, such as the detail section and footer section

Auto Resize

Controls whether the form automatically resizes to show all its controls when it is opened

Auto Center

Controls whether the form is automatically centered on the screen

Picture

The picture (if any) to use for the form's background

Picture Size Mode

Specifies whether any background picture should be stretched to fill the form

Picture Tiling

Controls whether any background picture should be repeated to fill the form

Moveable

Controls whether the form can be moved onscreen after it has been opened

Here's how you might use some of these properties to further customize the Catalogs form:

  1. Open the Catalogs form in design view.

  2. If the Properties window is not already open, press F4 to open it.

  3. Select the Format tab.

  4. Double-click in the Dividing Lines property to change its value from Yes to No.

  5. Change the Navigation Buttons property to No .

  6. Select the Data tab.

  7. Change the Allow Deletions property to No .

  8. Close the property sheet.

  9. Select Form View from the View drop-down list on the toolbar. The form will display as shown in Figure 13.5. Note that the dividing lines and navigation bar are gone.

    Figure 13.5. The Catalogs form after further design work.

    graphics/13fig05.jpg

  10. Click in the record selector to the left of one of the records, and then press the Delete key. Access will beep, and the status bar will display the message Records can't be deleted with this form .

  11. Save and close the form.

Caution

graphics/caution.gif

Setting Allow Deletions to No only prevents deleting entire records. You can still delete the contents of any individual control.




Absolute Beginner's Guide to MicrosoftR Access 2002
Absolute Beginner's Guide to MicrosoftR Access 2002
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 133

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