• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 13. Designing Custom Multitable ... > Creating a Subform Using the Subform...

Creating a Subform Using the Subform/Subreport Wizard

The frmPersonnelActionEntry form needs a subform in which to view the history of personnel actions for the employee displayed in the main part of the form. Access 2000's Subform/Subreport Wizard makes it possible for you to create a new subform at the same time that you add the subform field to the main form or, as in this example, a page in a Tab control. To take advantage of this feature, follow these steps:

  1. Click the Design View button on the toolbar if the frmPersonnelActionEntry form isn't already in Design view.

  2. Click the Control Wizards button to enable the Control Wizards if the button isn't already down.

  3. Click the second tab of the Tab control to bring its second page to the front. Click the Subform button in the Toolbox, and then click the top-left corner of the second Tab control page to open the first dialog of the Subform/Subreport Wizard.

  4. You can use this wizard either to create a new subform based on a table or query or to insert an existing subform (see Figure 13.44). (You learn how to insert an existing form as a subform in the section "Modifying the Design of Continuous Forms" later in this chapter.) For this example, select the Use Existing Tables and Queries option, and click Next to open the second dialog.

  5. The Subform/Subreport Wizard asks you to indicate which table or query the new subform is based on and which fields appear in the subform (see Figure 13.45). Select Table: Personnnel Actions in the Tables and Queries dropdown list. To expedite field selection, click the >> button to copy all the fields to the Selected Fields list. Select the paComments field in the Selected Fields list, and click the < button to remove this field from the list. Click Next to open the third dialog.

    Figure 13.44. Choosing whether to use an existing form as the subform or to use a table or query to create a new subform.

  6. The wizard now asks you to specify the link between the main form and the subform. You can select from a list of possible relationships that Access has determined or define your own link. Click the Define My Own option, and the wizard dialog changes to show four dropdown list text boxes

    Figure 13.45. Selecting the data source and fields for the new subform.

  7. In the upper Form/Report Fields list, select paID as the linking field; in the upper Subform/Subreport Fields list, also select paID as the linking field (see Figure 13.46). Click Next to go to the fourth and final dialog of the wizard.

    Figure 13.46. Defining the link between the main form (Master) and the subform (Child).

  8. Type sbfPATest as the name of this new subform, and click Finish to complete the subform's specifications. Access creates and saves the new form; it inserts the completed subform into the History page of the Tab control (see Figure 13.47). Access assigns the text you entered for the subform's name to the label for the subform.

  9. To change the subform from Datasheet view to a continuous subform, close the form, save your changes, open sbfPATest in Design view, and open the Form Properties window. In the Format page, change the value of the Default View property to Continuous Forms, then close and save changes to sbfPATest. Reopen frmPersonnelActionsEntry in Design view.

    Figure 13.47. The initial subform in Design view.

  10. To optimize the initial design of the subform, select all subform labels, drag them to the top of the Form Header section, and then click the Bold button. Drag the Detail section header up to the bottom of the labels. Adjust the width of the labels and the text boxes to suit their contents.

  11. To minimize the height of the Detail section records, select all the text boxes, drag the text box group to the top of the Detail section, and then drag the Form Footer bar to the bottom of the labels.

  12. Select the paScheduledDate text box and apply the mm/dd/yyyy format to assure Y2K compliance. Do the same for the paEffectiveDate text box. Add a dollar sign to the format string for the paAmount text box.

  13. Click the Form View button on the toolbar to check the appearance of the new subform. Your form appears as shown in Figure 13.48.

  14. Close the frmPersonnelActionEntry form and save your changes.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint