When you create a subform, you can design it to be displayed in Datasheet view, Form view, PivotTable view, or PivotChart view. You can also set the default view of the subform, and disable one or more views. You can switch the view of a subform when the main form is displayed in Form view.
Subforms are not displayed when a main form is opened in PivotTable or PivotChart view.
A subform displayed as a continuous form in Form view
You can make a form displayed in Form view look like a datasheet, but since it's displayed in Form view, it can display a form header and footer.
Synchronizing a form and a subform
When you create a form and subform based on tables that have a one-to-many relationship, the main form shows the "one" side of the relationship and the subform shows the "many" side of the relationship. The main form is synchronized with the subform so that the subform shows only records related to the record in the main form.
If you use a wizard to create a subform, or if you drag a form, table, or query from the Database window to another form to create a subform, Microsoft Access automatically synchronizes the main form with the subform if one of the following conditions is met:
- You have defined relationships for the tables you select, or you have defined relationships for the tables underlying the queries you select.
- The main form is based on a table with a primary key and the subform is based on a table that contains a field with the same name as that primary key and with the same or a compatible data type and field size. For example, in a Microsoft Access database, if the primary key of the table underlying the main form is an AutoNumber field and its FieldSize property is set to Long Integer, the corresponding field in the table underlying the subform should be a Number field with its FieldSize property set to Long Integer. If you select a query or queries, the underlying tables for the query or queries must meet these conditions.
A main form can have any number of subforms if you place each subform on the main form. You can also nest up to seven levels of subforms. This means you can have a subform within a main form, and you can have another subform within that subform, and so on. For example, you could have a main form that displays customers, a subform that displays orders, and another subform that displays order details. However, a form will not display subforms in PivotTable or PivotChart view.
Entering data using a form and subform
When you use a form with a subform to enter new records, Microsoft Access saves the current record in the main form when you enter data in the subform. This ensures that the records in the "many" table will have a record in the "one" table to relate to. It also automatically saves each record as you add it to the subform.