Work with subforms

Microsoft Office Access 2003

How you change the layout of a subform depends on the view in which the subform is displayed.

ShowIn Datasheet view

  1. Open the main form in Datasheet view.
  2. Do one or more of the following in the subform:

    To change the width of a column, drag the right edge of the column selector. To automatically size the column to fit its data, double-click the right edge of the column selector.

    To change the order of columns, click a column heading to select the column. Then click the column heading again, hold down the mouse button, and drag the column to a new location.

    To change the height of all the rows, drag the bottom edge of the row selector.

    To hide a column, click anywhere in the column, and then click Hide Columns on the Format menu.

    To show a hidden column, click Unhide Columns on the Format menu, and select the check box of the column you want to show.

    To freeze a column, click anywhere in the column, and then click Freeze Columns on the Format menu.

ShowIn Form view as a single or continuous form

  1. Open the main form in Design view. The subform is displayed in Design view in the subform control.
  2. Right-click the subform control and click Subform in New Window to open it in a separate window.
  3. Make changes to the subform's design.
  4. Save and close the subform window.
  5. Switch the main form to Form view to see the changes.

ShowIn PivotTable view

  1. Open the main form in Form view. The subform is displayed in its default view.
  2. On the View menu, point to Subforms, and then click PivotTable.
  3. Add fields from the field list to the filter, row, column, or detail area. You can also move fields from one area to another.
  4. Customize the data that is displayed in the view by filtering, grouping, or sorting data.

ShowIn PivotChart view

  1. Open the main form in Form view. The subform is displayed in its default view.
  2. On the View menu, point to Subforms, and then click PivotChart.
  3. Add fields from the field list to the filter, category, series, or data area. You can also move fields from one area to another.
  4. Customize the data that is displayed in the view by filtering, grouping, or sorting data.

Notes

  • If you change the width of a form displayed as a subform, you must also adjust the width of the subform control on the main form.
  • If the AllowDesignChanges property of the main form is set to All Views, you can change the design of the subform by using the property sheet in Form view. You can't, however, make changes to the subform control.

ShowMake a subform look like a datasheet that displays a header and a footer

You can display a form header and footer on a subform and arrange the text boxes and other controls so that the subform looks like a datasheet when you open the form in Form view.

  1. Open the form that you want to use as the subform in Design view.
  2. If you haven’t already added a form header and footer, on the View menu, click Form Header/Footer.
  3. In the detail section, arrange the text boxes and other controls that display data in a single row.
  4. In the form header, arrange the labels for the text boxes and other controls. Make sure that you align the labels in the form header with their associated controls in the detail section.
  5. In the form footer, if you want to total the records in the subform, create calculated controls.
  6. Size each section appropriately. For example, make the detail section the size of one row in a datasheet. If you don’t have any controls in the form footer, set its Height property to 0 or set its Visible property to No.
  7. Double-click the form selector to open the property sheet for the form.
  8. In the DefaultView property box, click Continuous Forms. This setting displays records in a form one after another, similar to a datasheet.

Notes

  • When you set DefaultView to Datasheet, Microsoft Access hides the header and footer when you display the form in Form view.
  • The Quarterly Orders form in the Northwind sample database has a continuous subform that has a form header and footer and looks like a datasheet. To view this form, point to Sample Databases on the Help menu, click either Northwind Sample Database or Northwind Sample Access Project, and then open the Quarterly Orders form in Design view.

ShowMove between a main form and a subform in Form view

Do one of the following:

  • To switch from the main form to the subform, click anywhere in the subform.
  • To switch from the subform back to the main form, click a control on the main form (not the background of the main form).
  • To move from the last field in the main form to the first field in the subform, press TAB.
  • To move from the first field in the subform back to the last field in the main form, press CTRL+SHIFT+TAB.
  • To move from the last field in the subform to the next field on the main form or to the first field in the next record or next page of the main form, press CTRL+TAB. If the Cycle property of the form is set to Current Record or Current Page, you must use the navigation buttons or other methods provided on the form to move to the next record.