How do I create an MS Access subform

MS Access Subforms are used for showing multiple rows of information. You could say one customer has many orders. The main form would contain the one record – the customer record. The subform would contain any related orders they have.

An MS Access subform is a form within a form.

For this demonstration I am using MS Access 2007. In this version of Access creating subforms has become an easy task.

Before you do anything you should define the relationships between your data. In this example I have a relationship between customers and orders. I am saying one customer can have many orders. The primary key “CustomerID” of the customers table is also used as the foreign key in the orders table. This is the key field that links the two tables together and provides the relationship.

Ok – so far so good.

Now let’s go ahead and create our subform.

In the navigation pane select the table of the main form (the one side of the relationship) – Here I select the customers table.

On the Ribbon click the tab marked ‘Create’.

In the area marked ‘Forms’ click on the ‘Form’ button.

Access will then create the main form and the related MS Access subform. Here you will notice I have the customer record at the top of the form.

A single record is shown and in the subform below I have a number of related orders. Recall in my table relationships I said one customer will have many related orders.

There are navigation buttons in both the main and the subform.

When you click on the navigation buttons at the bottom of the main form

 

the form will then cycle through the records and show the next customer and their related orders.

Here is a video showing another MS Access subform under Access 2003.

To learn more, check out this brand new ebook on the MS Access subform

Tags: , ,