Chapter 8

A Form for All Reasons

In This Chapter

arrow Creating forms the easy way with Form tools

arrow Building a form with the Form Wizard

arrow Adding the finishing touches

arrow Managing Data in Form View

Access forms are similar to paper forms in their function — they’re used in part to collect data — but Access forms go beyond paper forms by having a direct connection to the database tables that store the collected information. In the “old days,” after you completed a paper form, some poor soul had to manually organize and file each form in a file cabinet or tabulate results by hand. With the advent of electronic databases such as Access, the data typed into an electronic form is simultaneously placed in the file cabinet (the table) connected to that form.

Like reports and queries, forms are named and stored in the database file. Forms are full-fledged Access objects, so you can customize them easily to meet the needs of your business.

This chapter shows what forms can do for you, shows you how to make forms, and provides tips for customizing forms so they’re exactly what you need.

Generating Forms

Depending on your needs, you can create forms in three ways:

  • The Form tools make attractive forms with a click of the mouse.
  • The Form Wizard asks some questions and then creates an attractive form based on your answers.
  • The Form Design and Blank Form buttons let you start with a blank form and build from the ground up.

technicalstuff The Form tools and the Form Wizard make it easy to create a form. I focus on using these two methods to build forms. Building forms from scratch in Design or Layout view is beyond the scope of this book.

The Form Wizard and Form tools are a time-saving gift from your friends at Microsoft. Use them to create your forms. They do the hard stuff so all you have to do is provide the finishing touches.

tip Use these criteria to determine which form-building tool to use:

  • Use the Form tools if
    • You want all fields in the selected table or query to appear on the form.
    • You don’t want control over the type of style that is applied to the form.
  • Use the Form Wizard (covered later in this chapter) if
    • You want to select specific fields for your form.
    • You want to select fields from more than one table or query.
    • You want to choose from a list of layouts for your form.

Keeping it simple: Form tools

I have good and bad news about these tools:

  • Good news: They’re fast, and they don’t ask any questions or talk back!
  • Bad news: They’re extremely inflexible buggers.

    You want a larger font and a different background color? Keep it to yourself. The Form tools decide what font, colors, and layout you get.

tip After you create a form with a Form tool, you can modify the form. In this chapter, the “Customizing Form Parts” section gives you the straight scoop.

To create a form using one of the Forms buttons, open your database and follow these steps:

  1. From the Navigation pane, select the table or query that contains the data your new form should display.
  2. Click the Create tab on the Ribbon.

    Several button groups appear on the Ribbon, including the Forms group. (See Figure 8-1.)

  3. Click the form button of your choice from the Forms buttons.

    The Simple Form button is labeled Form. The Multiple Items and Split Form buttons are on the More Forms drop-down list.

    tip The sidebar “Meet the Form tools” shows the best Form tool for your data.

    A beautiful form appears before your eyes (and in Figure 8-2)!

  4. To finish your form, follow these steps:

    1. Click the Save button on the Quick Access Toolbar.

      The Save As dialog box appears.

    2. Type a name for the form in the dialog box, and click OK.

    Your form name appears on the Navigation pane.

image

Figure 8-1: The Create tab of the Ribbon holds the Forms buttons.

image

Figure 8-2: Form based on the Volunteers table using the Split Form button.

Granting most wishes: The Form Wizard

When you want to control field selection and the style of form design, use the Form Wizard.

As with all Access wizards, the Form Wizard steps you through the creation process. To use the Form Wizard, follow these steps:

  1. Open your database file.
  2. Click the Create tab on the Ribbon.

    Several button groups appear on the Ribbon, including the Forms group.

  3. Click the Form Wizard button. (Refer to Figure 8-1.)

    The Form Wizard springs into action, as shown in Figure 8-3.

  4. Using the Tables/Queries drop-down menu, select the source of the form’s fields:

    1. Click the down arrow to list the database’s tables and queries.
    2. Select the table or query that contains the fields you want to view with this form.

    The Form Wizard lists the available fields.

  5. Select the fields you want.

    • To select individual fields, double-click each field you want in the Available Fields list. (Again, see Figure 8-3.)
    • If you want to add all the fields from your table or query to your form, click the >> button in the middle of the screen.

    tip Feel free to select fields from different tables, provided the tables are related properly. The wizard will not let you select fields from unrelated tables. For more on relating tables, see Chapter 5, Table Tune Ups.

    tip To remove a field that you accidentally choose, double-click its name in the Selected Fields list. The field jumps back to the Available Fields side of the dialog box.

  6. After you’ve selected all the fields you want to include on your form, click Next.

    technicalstuff If you selected fields from more than one table, the Form Wizard takes a moment to ask how you want to organize the data in your form. If you choose to organize your data by the parent table (Chapter 5 shows how), you’ll be asked to show the child table data as either

    • Subform: Shows data from both tables on one form.
    • Linked form: Creates a button that, when clicked, will take you to a new form that displays the child table data.
  7. When the wizard asks about the form layout, choose one of the following layouts and then click Next:

    • Columnar: Records are shown one at a time.
    • Tabular: Multiple records are shown at the same time with an attractive style applied to the form.
    • Datasheet: Multiple records are shown at the same time in a rather unattractive spreadsheet-like way.
    • Justified: Arranges the fields on the form in a tidy block of rows that have pronounced left and right margins.

    tip Don’t know which layout is best? Check out the “Giving forms the right look” sidebar.

  8. Enter a descriptive title in the What Title Do You Want for Your Form? box at the top of the Form Wizard screen.

    tip There are good reasons to give your form a descriptive title rather than the default name (which is the name of the data source):

    • Tables and forms that share the same name can become confusing.
    • The name you type is used to save your form. Letters and numbers are allowed in form names. It’s a great opportunity to understand form usage through its name.
  9. Click Finish to open the form in Form view.

    Your new form appears onscreen, as shown in Figure 8-4.

    The Form Wizard automatically saves the form as part of the creation process. You don’t need to manually save and name it. All saved forms display in the Forms section of the Navigation pane.

image

Figure 8-3: Select the data source and fields you want to see on the form.

image

Figure 8-4: Lookin’ good. A form created by the Form Wizard.

tip The rest of this chapter shows how to customize forms you’ve created with the Form Wizard and Form tools.

Customizing Form Parts

The Access 2016 Form tools and Form Wizard do a great job building forms. In fact, for the typical user, they do just about everything — but they don’t always do it all. So you may need to do some form-tweaking.

If you know some form-design basics, you can clean up most of the problems left behind by the Form tools and Form Wizard.

This section shows how to change the overall look of the form. In particular, you get a handle on moving, sizing, labeling, and formatting controls on your forms. (A control is any design element on a form — say, a line, label, or data-entry box — that affects the appearance of the form. More about that later in the chapter.)

Taking the Layout view

You can make form-design changes in either Design or Layout view.

tip The sidebar “A form with a view” explains these views.

These instructions concentrate on Layout view because it’s easier to use.

To enter Layout view, follow these steps:

  1. On the Navigation pane, right-click the form you’d like to modify.

    The shortcut menu appears.

  2. Select Layout View from the shortcut menu.

tip How can you tell whether you’re in Layout view or Form view? Look at the status bar in the lower left corner of your screen. It tells you the current view for an open form.

The theme’s the thing

After building your new form with the Form Wizard or Form tools, you may not like the appearance that the tools have chosen for your form. Fear not! It’s easy to change the look of the form by using the Theme group of buttons. Here’s how:

  1. From the Navigation pane, right-click the form that needs a new look and choose Layout View from the menu that appears.

    The form opens in Layout view.

  2. Click the Design tab on the Ribbon.

    Several button groups appear on the Ribbon, including the Themes group. (See Figure 8-5.)

  3. Click the Themes button.

    An illustrated list (called a Gallery) of themes opens.

  4. Roll the mouse pointer slowly over each theme.

    The form in the background changes to match the highlighted theme.

  5. When you’ve found the theme you like, click it to select it from the drop-down list and apply it to the form.
image

Figure 8-5: The Themes group on the Ribbon.

tip Choose a theme with fonts and colors that are easy on the eyes, such as soft colors and simple fonts. Form users will thank you for it!

Managing form controls

A control is any design element (such as a line, label, or data-entry text box) that appears on a form. The Form Wizard and Form tools do a fine job of constructing forms but often don’t place or size them just right. This section discusses how to take charge of your controls.

Control types

The two most common control types display data pulled from an underlying table or query (as with a text box) or supply a design element to keep the data organized on the form (as with a line).

Here are the most common form controls:

  • Text box: The box where you type your data.

    Text boxes are either bound (a way of saying linked) to a table field or unbound (containing a calculation derived from other fields in a table).

  • Label: The descriptive text next to the control or the title of the form.
  • Combo box: A drop-down list of choices.
  • List box: A box that contains a list of choices, from which the user can choose more than one item.
  • Check box: A square box attached to a field that can store only true/false, on/off, or yes/no answers. For example, a personnel table may have a field called Married. Either you are or you aren’t.
  • Option Group: A box that contains related choices where only one choice is allowed. For example, suppose a marital status field contains Married, Single, and Divorced choices. The option group control bound to that field would allow only one of those three choices.
  • Subform: A form inside another form.

    Subforms usually display the “many” records of the “one” record when tables are in a one-to-many relationship. (For details on table relationships, see Chapter 5.)

tip If your form is columnar (most are) and you’ve created it with the Form Wizard or Form tools, all text boxes and labels on the form are anchored. Anchored controls behave as a group when you size them. Additionally, you can move anchored controls as long as they’re among the other controls in a group; you can’t move them if they’re outside the group.

Creating controls

Most controls have a Control Wizard associated with them. Once you create the control, the wizard appears and guides you through the process. Here are the general steps to create a control:

  1. From the Navigation pane, right-click the form that’s to get the new control and choose Design View.
  2. Click the Design tab on the Ribbon if necessary.

    The Controls group appears (see Figure 8-6).

  3. From the Controls group, click the appropriate button for the new control (such as combo box) and roll the mouse onto the form.

    The mouse pointer changes to a plus sign and icon of the control selected.

  4. Position the mouse at the location on the form where you’d like the new control to appear, then press and drag diagonally to draw the control.

    The control wizard appears if applicable.

  5. If you’ve selected a control that has a Control Wizard, follow the steps in the Control Wizard and then click Finish.

    The control appears on the form.

image

Figure 8-6: The Controls group on the Ribbon.

tip Don’t see a Control Wizard after creating a new control? Control Wizards are turned on by default. If, for some reason, yours are not on, choose Use Control Wizards toward the bottom of the Controls group. Note: Click the More button (dash with down arrowhead button) located at the lower right of the Controls group to see the Use Control Wizards option (see Figure 8-7).

image

Figure 8-7: If the wizards aren’t coming out to play, turn them on!

Moving controls

To move a control, enter Layout view (as shown previously in this chapter) and then follow these steps:

  1. Put the mouse pointer anywhere on the control that you want to move.

    The mouse pointer changes to a four-headed arrow.

  2. Hold down the left mouse button.

    The control is selected, so a thick border appears around it. See Figure 8-8 for an example of a selected control.

    tip To select additional controls such as a label corresponding to a text box, press and hold the Ctrl key while clicking the additional control. A thick border will appear around all selected controls.

  3. Drag the control to its new location.

    A line follows the mouse pointer as you drag up, down, left, or right.

  4. When the control is in position, release the mouse button.

    The control drops smoothly into place.

    tip If you don’t like an adjustment you’ve made, press Ctrl+Z to undo the change and start over from scratch. Access has multiple undo levels, so play to your heart’s content; you can always undo any mistakes.

image

Figure 8-8: A selected control on the Customers form.

Sizing controls

Sometimes the Form Wizard and Form tools fall a bit short (literally) when they’re sizing your text boxes and labels. A common problem is that the last part of the information displayed in a label or text box is cut off.

To size a control, enter Layout view (as shown previously in this chapter) and then follow these steps:

  1. Put the mouse pointer on the control that you want to size.

    The mouse pointer changes to a four-headed arrow. If the controls are anchored, it doesn’t matter which control you roll the mouse pointer over.

  2. Click to select the control.

    A thick border appears around the control to indicate that the control is selected.

  3. Move the mouse pointer to the edge of the selected control.

    A double-arrow pointer shape appears.

  4. Click and drag to resize the control.

    technicalstuff Anchored controls size together horizontally within the same column and vertically within the same row. So when you change the width of one control in a column, all are changed to that same width. When you change the height of one control in a row, all in that row are changed to the same height.

Editing labels

The Form Wizard and Form tools use field names or captions as control labels when they build your forms. If you abbreviated a field name (say, FName for First Name) or caption when creating a table, that abbreviation will become the label for the control created by the Form Wizard and Form tools. So, if a label doesn’t quite say what it should, you’ll need to know how to edit the text in it.

To edit a label, enter Layout view (as shown previously in this chapter) and try this:

  1. Put the mouse pointer anywhere on the label that you want to edit.

    The mouse pointer changes to a four-headed arrow.

  2. Click to select the label control.

    A thick border indicates that the control is selected.

  3. Click the word you’d like to edit.

    A blinking cursor appears on the word.

  4. Edit the word.
  5. Click outside of the label control.

    The label is deselected and the edit is preserved.

Deleting controls

Sometimes an Access form contains an unneeded or unwanted control:

  • Maybe you selected an unwanted field while using the Form Wizard.
  • Maybe you added a control (such as a line) and in retrospect decided it wasn’t needed.
  • Maybe you’re just tired of looking at that control.

Here’s how you remove the control:

  1. In Layout view, put the mouse pointer anywhere on the control that you want to delete.

    The arrow mouse pointer changes to a four-headed arrow.

  2. Click to select the control.

    A thick border appears around the control, indicating that it is selected.

  3. Tap the Delete key on your keyboard.

    The unwanted control disappears into digital oblivion.

technicalstuff When you delete a text box, its corresponding label will also be deleted. When you delete a label, however, its corresponding text box (if there is one) won’t be deleted. Go figure!

Managing Data in Form View

You’re done with form design and ready to take it for a drive. This section explains how to move between records, start a new record, and more.

Navigating and finding records

How do you move between records on the form? The Navigation buttons at the lower left of the form (see Figure 8-9) make it easy to:

  • Move between records: Click the right arrowhead (>) to move forward, the left arrowhead (<) to move backward, the right arrowhead with line (>|) to move to the last record, and the left arrowhead with line (<|) to move to the first record.
  • Go to a new record: Click the right arrowhead with asterisk (>*) button to go to a new record.
  • Search for data: Type a search word in the Search box and Access will find the first record that contains your search word. For example, type “Prince” in the search box and Access will dutifully move to the first record that contains the word Prince.
image

Figure 8-9: Navigation 101.

Saving, clearing, and deleting

Saving is very confusing to those from the Word and Excel world entering the Access world. In most other programs, you enter something new in a document and click Save to save your work. Access is different. The second you move to a new record or close a form, your good friend Access saves the record for you. So, it’s very hard to lose data in Access! Clearing field data and deleting records is not quite so automatic, but that’s a good thing.

tip If you’re the overly cautious type, you can save a record before moving off of it or closing the form by clicking the Save button in the Records group of the Home Ribbon (see Figure 8-10).

image

Figure 8-10: Record selectors and the ever-popular Records group on the Home Ribbon.

To clear the contents of a field, follow these steps:

  1. While in Form view, tab to the field that contains the unwanted data.

    The contents of the field are selected.

  2. Tap the Delete key on your keyboard.

    The contents of the field are deleted.

Here’s how to delete an entire record:

  1. While in Form view, navigate to the poor record that will meet its demise.
  2. Click the Record Selector button located on the left edge of the form (see Figure 8-10).
  3. Click Delete Record in the Records group on the Home tab of the Ribbon.

    Access asks you if you want to delete the record and related records if appropriate.

  4. Click Yes in the confirmation dialog box to delete the record.

    Adios record!

warning! Deleted records can’t be undone. Confirm you’re on the correct record before you delete, and back up your database file often should you need to restore a deleted record!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.217.41