Creating a Basic Transaction-Processing Form with the Form Wizard

The content and appearance of your form depend on its use in your database application. Database applications fall into two basic categories:

  • Transaction-processing applications add new records to tables, or edit or delete existing records. Transaction-processing applications require write access to (permissions for) the tables that are linked to the form.

  • Decision-support applications supply information as graphs, tables, or individual data elements but don't allow the user to add or edit data. Decision-support applications require only read access to the tables that are linked to the form.

The form that you create in this example is typical of transaction-processing forms used to add new records to the many side of a one-to-many relationship. Adding line items to an invoice is an example of when a form of this kind called a one-to-many form is necessary. The objective of the HRActions form is to add new records to the HRActions table or let you edit the existing records.

Maintaining a record of employee performance reviews and actions resulting from the reviews is one of the primary responsibilities of personnel departments. For organizations with more than a few employees, a database is an effective tool for recording dates on which employees were hired, promoted, demoted, or terminated, and the justification for actions taken. This information often critical in the defense of wrongful termination or other litigation brought by disgruntled former (or even current) employees. Human resources the more politically correct term for personnel databases also can handle scheduling of periodic reviews and aid in assuring that managers or supervisors handle their human resources (HR) responsibilities in a timely manner.

graphics/power_tools.gif

If you didn't add records to the HRActions table when you created it in Chapter 5, "Working with Jet Databases and Tables," you can add them with the HRActions form you create in the following sections with the assistance of Access's Form Wizard. If you didn't create the HRActions table, you can import it from the Forms14.mdb database in the \Seua11\Chaptr14 folder of the accompanying CD-ROM.

Tip

If you import the HRActions table from Forms14.mdb, make sure to establish a one-to-many relationship between the Employees and HRActions table, as described in Chapter 5.


If you need help for creating or altering relationships, see "Establishing Relationships between Tables," p. 189.


The easiest way to create a form and subform combination is with the Access Form Wizard. The Form Wizard lets you create forms (with or without subforms) that contain fields from one or more tables or queries. The Form Wizard creates the basic design of the form and subform and adds text box controls to display and edit the values of data fields.

To create the HRActions form in Northwind.mdb with the Form Wizard, follow these steps:

  1. graphics/form_wizard.gif Click the Forms shortcut of the Database window and then click the New button to open the New Form dialog.

  2. Select Form Wizard from the list in the New Form dialog. (The Design View choice opens a blank form in Design view).

    Note

    The various AutoForm choices automatically create forms with the specified layouts: Columnar, Tabular, and Datasheet. The Chart Wizard choice invokes the Chart Wizard to add a graph or chart (not a PivotChart) to your form, and the PivotTable Wizard choice helps you create a form based on an Excel PivotTable report, not an OWC PivotTable. Using the Chart Wizard is one of the subjects of Chapter 18, "Adding Graphs, PivotCharts, and PivotTables."

    For an example of how the Chart Wizard is used, see "Using the Chart Wizard to Create an Unlinked Graph," p. 706.


  3. The drop-down list at the bottom of the New Form dialog lists the existing tables and queries that can serve as a source of data for a form. For this example, select the Employees table (see Figure 14.1).

    Figure 14.1. The New Form dialog displays initial selections for the HRActions form.

    graphics/14fig01.gif

  4. Click OK, and Access displays the first dialog of the Form Wizard.

  5. Click to select the EmployeeID field in the Available Fields list, and then click the > button to move the EmployeeID field from the Available Fields list to the Selected Fields list. Alternatively, you can double-click the field name to move it.

  6. Repeat step 5 for the LastName, FirstName, and Title fields of the Employees table so that you can edit data in these fields (see Figure 14.2).

    Figure 14.2. Select the Employees fields to display in your form. The EmployeeID field is an AutoNumber field, so you can't edit its value.

    graphics/14fig02.gif

  7. Open the Tables/Queries drop-down list, and select the HRActions table to serve as the data source for the subform. The Available Fields list changes to show the available fields in the HRActions table.

  8. Click the >> button to copy all fields from the Available Fields list to the Selected Fields list.

    Note

    If you haven't established a one-to-many relationship between the Employees and HRActions table, you receive an error message at this point. When you acknowledge the error message, the Relationships window opens. Add the relationship between EmployeeID fields of the two tables and close the Relationships window. You must then click Cancel, and start over from step 1.

    Tip

    It's easy to change the sequence of location of form fields from the default the order of fields in the table proposed by the Wizard and added by clicking the >> button. Select the first field and click > to position it at the upper-left corner of the form. Select each field and then click > to add the remaining fields in the sequence you want. If you've added many fields to a form, but decide to change your layout, it's often faster to delete the newly created form, and then start over with the Wizard.

  9. The EmployeeID field from the HRActions table is included in the Selected Fields list, but you don't need to include it in the subform. The form determines the current Employees record. Select the HRActions.EmployeeID field in the list of Selected Fields and then click the < button to remove this field from the Selected Fields list (see Figure 14.3). When you remove the HRActions.EmployeeID field, it returns to the Available Fields list. The EmployeeID field that remains in the Selected Fields list is from the Employees table.

    Figure 14.3. Add all HRActions fields except the HRActions. EmployeeID field to provide subform fields.

    graphics/14fig03.gif

  10. Click Next to display the Form Wizard's second dialog, which is shown in Figure 14.4.

    Figure 14.4. The Form Wizard sets default values for a form-subform relationship based on the one-to-many relationship of the Employees and HRActions tables.

    graphics/14fig04.jpg

    Tip

    Verify in the second Wizard dialog that the fields you specified in the first dialog appear in the proper form or subform location. The picture in the upper-right area of the Form Wizard dialog shows the fields of the master form (from the Employees table), with a sunken frame that lists the fields of the subform (from the HRActions table). If you realize that you made an error or if you change your mind about something and you're on a later step of the Form Wizard, you can click the Back button to return to and modify your previous choices. You can also click Cancel at any time to abort the form-creation process and return to the Database window.

  11. The fields you've selected to appear on the form come from two different tables, so the Form Wizard asks how you want to view the data. Because you want to view the data by employee, with the employee's human resources action data in a subform, accept By Employees (the default) and make sure that the Form with Subform(s) option is selected (refer to Figure 14.4).

    Note

    In one-to-many forms, the subform needs to be linked to the main form so that all records displayed in the subform are related to the current record displayed in the main form. The Form Wizard obtains the information it needs to link the main form and subform from a join in the Relationships window (in this case, between the Employees table and the HRActions table).

  12. Click Next to open the third Wizard dialog, which asks you to select the layout style for the subform. Clicking different options gives you a preview thumbnail in the dialog. Select the Tabular option (see Figure 14.5). This option creates a subform that displays the data from the HRActions table in a tabular format that is similar to Datasheet view but has a structure in which you can change the formatting (colors, column headings, and so on).

    Figure 14.5. Select a tabular layout for the HRActions form and subform to allow specifying custom formatting and other property values for the subform fields.

    graphics/14fig05.jpg

    Note

    graphics/access_2002_new_icon.gif

    Access 2002 added to the Wizard two new display options PivotTable and PivotChart for the subform. Chapter 18 shows you how to use the Form Wizard to generate PivotTable and PivotChart subforms.

  13. Click Next to move to the fourth Wizard dialog, which asks you to select a style for the new form. The Access Form Wizard has several predefined styles. Because the sample form you're creating is for use by a data-entry operator and doesn't require special effects to decorate the form's background, accept the Standard default (see Figure 14.6).

    Figure 14.6. Select a predefined form style in the Form Wizard's fourth dialog. The conservative Standard style is the best choice for most data-entry forms.

    graphics/14fig06.jpg

  14. Click Next to open the last Form Wizard dialog, which asks you to type a name for the master form and subform. Type frmHRActions in the Form text box and sbfHRActions in the Subform text box (see Figure 14.7). Accept the default Open the Form to View or Enter Information option, and then click Finish to complete your form. (If you want Access to display help for working with your completed form, select the Display Help on Working with the Form? check box before you click Finish.)

    Figure 14.7. Type a name for the main form and its subform. Access developers commonly use frm and sbf prefixes for forms and subforms, respectively.

    graphics/14fig07.jpg

Tip

Access suggests default names for the form and any subforms; but the default names seldom are appropriate to production databases. When naming forms, make sure to specify names that are indicative of what the form really does. Also, unless you intend to use the subform with other forms, make sure that you include the name of the main form (or an abbreviation) in the name of your subform so that the relationship between the form and subform is evident. Using standard Access naming conventions frm and sbf prefixes for forms and subforms, respectively is the approach used by most Access developers. You later can set the Caption property value of the form to a name meaningful to users.


graphics/ne_objects.gif The Form Wizard creates and automatically saves the form and subform with the names you specified in the last dialog, and then opens the form (see Figure 14.8).

Figure 14.8. The basic frmHRActions form created by the Form Wizard is the starting point of the final form-design process.

graphics/14fig08.jpg

On the main form, the Form Wizard creates a single column of text boxes each with an associated label for entering or editing data values in three of the four fields from the Employees table that you selected for the master form. The subform contains all the fields from the HRActions table (except the EmployeeID field) arranged in a tabular layout. Access uses the fields' Caption property values as default text box labels and also as column headings for the tabular subform. Access adds the name that you entered for the subform as the label for the subform container.

In Figure 14.8, notice that the Effective Date and the remaining fields of the HRActions table are partially or completely obscured, and scroll bars appear in the subform area. The subform is larger than the area created for it in the main form, so Access automatically adds scroll bars to let you access all data displayed in the subform. The subform's record navigation buttons let you scroll all records related to the current record of the main form.

The basic form as created by the Form Wizard needs many cosmetic adjustments to the layout of the main form and, especially, the subform. The remaining discussions and exercises in this chapter show you how to modify forms created with the Form Wizard; you can apply these form-editing skills when you create your own forms from scratch, as described in the next chapter.

Tip

No matter how adept you become at designing Access forms, using the Form Wizard to create the basic form design saves you time.




Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

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