Special Edition Using Microsoft Office Access 2003

The objective of the following procedure is to rearrange the controls on the frmHRActions form so that all the elements on the form (and its subform) are completely visible in the form window. Another objective is to optimize the position of the fields for data entry. After you complete the following steps, your main form with its embedded subform appears as shown in Figure 14.20.

Figure 14.20. The frmHRActions form appears as shown here after relocating and resizing its control objects. You modify the subform design in the next section.

Setting Properties of the Main Form

To change the color of form objects and rearrange the controls of the frmHRActions form to correspond with the positions shown in Figure 14.20, follow these steps:

  1. Close the frmHRActions form, and don't save any changes you made in the preceding sections.

  2. Select frmHRActions from the Forms list in the Database window and click the Design button.

  3. Expand the Form Design window to add working room. Alternatively, click the Maximize window button to maximize the Form Design window.

  4. Click the Form Select button, and then click the Properties button on the toolbar.

  5. Click the Format tab of the Properties window and then scroll through the properties list until you see Grid X and Grid Y. Change the Grid X property to 10 and the Grid Y property to 12. (Metric users might prefer a 5x5 grid, providing 2mm resolution.)

  6. Close the Properties window by clicking the Properties button again.

  7. Drag the right margin of the form from its present position (5.5 inches) to 6.5 inches.

  8. Delete the FirstName label (click the label and then press Delete). Select the FirstName field and drag it to a position to the right of the LastName field (refer to Figure 14.20).

  9. Edit the LastName label to Name:, the EmployeeID label to ID:, and the Title label to Title:.

  10. Resize the labels and their text boxes to suit their content and reduce the space between each text box and its label. At this point, you must estimate the required width of the text box.

  11. Click and drag the LastName, FirstName, and Title text boxes and their associated labels to the positions shown in Figure 14.20.

  12. Delete the sbfHRActions field label (the size and content of the subform is sufficient to identify it) and drag the subform control to a position below the FirstName and LastName fields (refer to Figure 14.20).

  13. Click and drag the Form Footer bar to approximately 2.5 inches. (Alternatively, you can type the Detail section's height directly in the Height property on the Format sheet of the Properties window.) At present, the dimensions of your form are 6.5x2.5 inches.

  14. Resize the sbfHRActions subform control on the form so that its left, right, and bottom edges are one grid mark inside the edges of the form (this makes the sbfHRActions subform control about 6.25x1 7/8 inches).

  15. Click the text label of the EmployeeID field to select it and then click the Bold and Align Right buttons on the Formatting toolbar to make the text label bold and right-justified.

  16. Double-click the Format Painter button on the toolbar (remember that this step locks the Format Painter).

  17. In turn, click the text labels for all the remaining controls on the form to apply the formatting with the Format Painter.

  18. Click the Format Painter button on the toolbar again to turn off the Format Painter.

  19. Select the form, and click the Properties button. Click the Data tab, and set the Allow Additions and Allow Deletions properties to No. Setting these property values to No prevents you from adding or deleting employee records in this form. You can, however, edit employee names, which might change as the result of a marriage (or divorce).

  20. Click the Format tab, set the Record Selectors, Allow Datasheet View, Allow PivotTable View, and Allow PivotChart View property values to No.

  21. Click the Save button (or press Ctrl+S) to save your changes to the frmHRActions form, and close the Properties window.

You might need to adjust the sizes of some controls individually to make their appearance consistent with other controls. When you complete your rearrangement, click the Form View button to review your work. In particular, you might need to adjust the width of the LastName and FirstName text boxes to accommodate data in Employees table.

If you encounter problems when you open the form in Form view, see the "Form Problems" topic of the "Troubleshooting" section near the end of the chapter.

Setting the Properties of a Subform

You can learn about modifying the properties of a subform by working with the subform that's used to create the history of prior HRActions for an employee. In this example, editing or deleting entries using the subform isn't allowed, but you can add new entries. The subform needs to be modified so that all its columns are readable without horizontal scrolling. When you complete the following steps, the sbfHRActions subform appears as shown in Figure 14.21.

Figure 14.21. The sbfHRActions subform in the frmHRActions form appears as shown here after modifying its field sizes and overall dimensions.

Tip

Although you can use the in-situ subform editing feature to alter the design of a subform, in most cases it's easier to use the traditional method of subform design modification. In-situ editing is better suited for changing subform property values than for altering subform dimensions.

To change the properties of the sbfHRActions subform, follow these steps:

  1. Right-click the sbfHRActions subform and choose Subform in New Window from the context menu. The new subform window, a feature added by Access 2002, replaces the in-situ subform.

    Tip

    When you close a subform that's been opened in its own window, the in-situ subform disappears from Form Design view. To regain the in-situ version, click Form view and then Form Design view.

  2. Select the form and use the Properties window to make sure that the Grid X and Grid Y properties are both set to 24. In this case, the finer grid lets you make more precise changes to the size of subform controls. Close the Properties window.

  3. Using the same techniques you used when working with the main form, resize the label boxes in the Form Header section of the form so that they match what you see in Figure 14.21. Use the Format Painter to center the text in every text label in the Form Header section.

  4. Adjust the field text boxes in the Detail section of the form to line up with the headings in the Form Header section (see Figure 14.22).

    Figure 14.22. Choosing New Window from the context menu opens the subform in a windows superimposed on the Form Design view. Adjust the widths of the subform's labels and fields as shown here.

    Tip

    As you make changes to the subform, click the Save button on the toolbar to save them. It's frustrating to spend several minutes adjusting the positions and formatting of fields, and then lose your changes by an inadvertent error.

  5. Drag the right edge of the form to the left until the form is one grid width wider than fields (about 7 1/2 inches) and then drag the Form Footer upward so that the Detail section is about 5/8 inches high.

  6. With the subform window active, click Form Select button and the Properties button on the toolbar to display the Properties window for the subform.

  7. Click the Data tab in the Properties window so that the Allow Edits, Allow Deletions, and Allow Additions properties are visible.

  8. Set the Allow Edits and Allow Deletions property values to No; this setting prevents the user from editing or deleting earlier Personnel Action records displayed in this subform.

    Note

    You can set the Data Entry property to Yes to achieve a result that is similar to setting the Allow Edits and Allow Deletions property to No and the Allow Additions property to Yes. When you set the Data Entry property to Yes, however, only the tentative new record appears no prior entries appear in the subform.

  9. Save your changes, close the sbfHRActions subform, and close and reopen the form in Design view.

    Tip

    You must close and reopen the main form to make changes you apply to a subform in the window appear in Form view. The form embeds a copy of the subform; the embedded copy doesn't change until you close and reopen the form.

  10. Adjust the width of the subform to about 7 3/8 inches, and drag the right margin of the form to the right edge of the subform.

  11. Save your changes, close and re-open the form in Form view, and restore the form window if its maximized. Then, choose Windows, Size to Fit Form. Your form appears as shown in Figure 14.23.

    Figure 14.23. The completed frmHRActions and sbfHRActions forms in Form view display a single HRActions record for Northwind Traders' first employee.

Notice in Figure 14.23 that there's no horizontal scroll bar and that the appearance and visibility of fields and column headings in the subform have improved. By changing the size of the subform control in the main form and resizing the subform to fit completely within the subform control (allowing room for the vertical scroll bar), the subform fits completely in the main form. Notice also the tentative append record that's visible as the second record in the subform.

If problems occur when you attempt to add a new subform record for an employee, see the "Subform Problems" topic of the "Troubleshooting" section near the end of the chapter.

Категории