Creating “Subforms”

If you want to create a single form to display information from two or more related tables in your database, you need to use “Subforms”.

With “Subforms” we can display data from the first table (“Parent table”), and all related data from any other table (“Child table”), with a “Subform” in a main form.

This is an easy way for the user as he needs to go through only one form to add data to more than one table.

The form that makes use of “Subforms” represents the “one” side of the “one to many” relationship.

The “Subform” represents the “many” side of the relationship between the two tables.

You can display data in a “Subform” in “Form view” (shows only one record) or “Datasheet View” (shows multiple records) which are most used.

You can add multiple “Subforms” on a main form.

You can also create “Subforms” in “Subforms”.

Access creates “Subforms” when you start to create two forms, one for each table.

The first thing I will make is what I call ” Employee Main Form”.
I close the form and make a second “OrdersSubForm”.

I close the second form and open the first one again.

Now I have to drag the second form into the first form.
How we do it?

We minimise the first form database window so we can see the window where we see all our forms.

Now we drag the second form (“OrdersSubForm”) in our first form (“Employee Main Form”).

Result as in “Design view”.

Let us now open our form, we see that the subform is inserted into the main form.

You can see that each form has its own navigation to easily navigate from one record to next.
We also see the number of records per form.

Showing “Subform” data

When we create “Subforms”, we show the data in the “Form View” or “Datasheet View”.

We may, however, display the data of the subform in any manner.

To do this, while our main form is open, we select a field in our first “Subform”, choose “View” from the menu bar and choose “Datasheet View” for the subform to be in “Datasheet view”.

In Access 2003, this is slightly modified. You select “View”and choose which view you want to open for the “Subform”.

Awesome!
You've completed Lesson 13
START NEXT LESSON