How to Create a Subform from a Table in Access 2016
You can use a table to create a subform — a form within a form. The subform contains data that is relevant to the the data in the main form.
A subform is a form that is nested inside of another form. It usually contains data that is associated with the record that is currently open in the main form.
For example, you could have a form that displays an order, and a subform that displays each item within the order.
Or, you could have a form that displays a country, with a subform that displays each city within that country.
Below is a step-by-step guide to creating a form and subform from a table.
-
Create a New Form
In the left Navigation Pane, select the table to base your form/subform on and select Form from the Ribbon (on the Create tab).
In order for this to work, the selected table must be the "one" part of a one-to-many relationship.
See below for more information.
-
The Form & Subform
The form and its subform are instantly created and displayed in Layout View.
The subform appears in Datasheet View under the other fields of the main form.
A Closer look at the Subform
Let's see how the subform appears in the various views, as well as how it gets its data.
-
Form View
Switch to Form View (by clicking the Form View icon in the bottom right of Access).
Navigate through the main form by clicking the Next Record icon at the bottom of the form.
As you navigate through the records, the contents of the subform will update to only those records that are associated with the parent form.
-
Design View
Switch to Design View (by clicking the Design View icon in the bottom right of Access).
The subform appears as a box, with its data source displayed. In this example, the data source is Table.Albums (i.e. the Albums table).
You can use Design View to customize the subform. For example, you can open the Property Sheet (by clicking Property Sheet in the Design tab of the Ribbon) and adjust the various properties as required.
-
The Subform's Source
Clicking on the Data tab of the Property Sheet will reveal the subform's source, as well as the field that links the subform to the parent form.
The Source Object property determines what object is displayed in the control.
The Link Child Fields property specifies which field or fields in the subform link the subform to the parent form.
The Link Master Fields property specifies which field or fields on the parent form link the parent form to the subform.
How it Works
Creating a subform like this only works if that table is part of a relationship. Access sees that there's a relationship, so it helpfully creates the subform automatically.
More specifically, the table must be the "one" part of a one-to-many relationship.
If you create a form from the "many" table, you won't get a subform. The form will be a simple form based on the selected table.
If you create a form from a table that is not part of a relationship, there's no need for a subform (as there's no related data in another table).
A subform is sometimes referred to as a one-to-many form, as it will display the "many" part of a one-to-many relationship (with the parent form displaying the "one" part).
Subforms are also often referred to as subdatasheets.
A form/subform combination is sometimes referred to as a hierarchical form, a master/detail form, or a parent/child form.
Subforms vs... Subforms
If you create a subform using the SubForm Wizard, you will probably end up with two forms; the main form, and the subform. Both forms will be saved under the Forms node in the Navigation Pane.
When you create a subform from a table (like in the above example), you won't get the extra form. This is because the subform/subreport control is displaying data directly from the table.
So technically, it could be argued whether this is actually a subform, or just a subdatasheet. Either way, it displays the same result for the user.
If you don't want to display all fields from the table, you could use a query as the source object, or create a subform using the SubForm Wizard.
Don't need a Subform?
As mentioned, Access is trying to be helpful when it creates the subform automatically for you.
However, if you don't need the subform, you can simply delete it. Just switch to Layout View or Design View, right-click on the subform, then select Delete from the contextual menu.
Add a Subform to an Existing Form
If you already have a form that you'd like to add a subform to, you can go ahead and add a subform to the existing form by adding a subform control.