Forms & Reports

How to Use Subforms in Microsoft Access Effectively

Subforms are one of the most powerful features in Access for displaying related data. Learn how to create, link, and customize them correctly.

M
MS Access Blog
5 min read
How to Use Subforms in Microsoft Access Effectively

If you have ever needed to show an order alongside all its line items, or a customer alongside all their contacts, subforms are the answer. A subform is a form embedded inside another form, and it is one of the most powerful tools in the Access developer's toolkit.

What Is a Subform?

A subform is simply a form that is displayed inside another form. The outer form is called the main form or parent form. The inner form is the subform or child form.

The two forms are linked by a relationship. When you navigate to a customer record in the main form, the subform automatically filters to show only that customer's orders. This parent-child relationship is what makes subforms so useful.

When to Use a Subform

Use a subform when you have a one-to-many relationship and you want to display both sides on the same screen:

  • Customer → Orders
  • Order → Order Line Items
  • Employee → Time Entries
  • Project → Tasks
  • Invoice → Invoice Lines

Creating a Subform: Two Methods

Method 1: The Subform Wizard

This is the easiest approach for beginners.

  1. Open the main form in Design View
  2. Make sure the Use Control Wizards button is active in the Controls group (it looks like a magic wand)
  3. Click the Subform/Subreport control in the Controls group
  4. Draw a rectangle on the main form where you want the subform to appear
  5. The Subform Wizard opens — choose whether to use an existing form or create a new one from a table/query
  6. Select the table or query for the subform data
  7. Choose the fields to display
  8. Define the link fields (the wizard usually detects these automatically from your relationships)
  9. Name the subform and click Finish

Method 2: Drag and Drop

If you already have a form built that you want to use as a subform:

  1. Open the main form in Design View
  2. Open the Navigation Pane so you can see your forms list
  3. Drag the child form from the Navigation Pane onto the main form's design surface
  4. Access creates a subform control and attempts to set the link fields automatically

Configuring the Link Fields

The link fields are what connect the main form to the subform. They tell Access: "when the main form shows CustomerID 42, show only the subform records where CustomerID = 42."

To check or set the link fields:

  1. Click the subform control (the outer border, not inside the subform)
  2. Open the Property Sheet (F4)
  3. Click the Data tab
  4. Look at Link Master Fields and Link Child Fields

Link Master Fields is the field on the main form (usually the primary key, like CustomerID). Link Child Fields is the matching field on the subform (the foreign key, like CustomerID in the Orders table).

If these are blank or wrong, your subform will show all records instead of filtered records.

Subform Views

A subform can display in three views:

  • Datasheet — looks like a spreadsheet grid; best for showing many records at once
  • Single Form — shows one record at a time; useful when the child record has many fields
  • Continuous Forms — shows multiple records stacked vertically; a middle ground between Datasheet and Single Form

Set the view using the subform's Default View property in Design View.

Sizing and Scrolling

Subforms have their own scroll bars when the content exceeds the visible area. You can control this:

  • Scroll Bars property: Both, Horizontal Only, Vertical Only, or Neither
  • Navigation Buttons property: Yes/No — controls whether the record navigation bar appears at the bottom

For a clean look, set Navigation Buttons to No and Scroll Bars to Vertical Only for most datasheet-style subforms.

Referencing Subform Data in the Main Form

You can reference values in the subform from the main form using this syntax:

Forms![MainFormName]![SubformControlName].Form![FieldName]

For example, to show the total of all order amounts in a text box on the main form:

=Sum([Forms]![CustomerForm]![OrdersSubform].Form![OrderTotal])

Or more simply, in a calculated control on the main form:

=[OrdersSubform].Form![OrderTotal]

Nested Subforms

Access supports subforms within subforms (up to two levels deep). This is useful for three-level hierarchies like Customer → Order → Order Line Items.

To create a nested subform, simply add a subform control inside your first subform's design. Be careful with nested subforms — they can become slow and visually complex. Consider whether a separate form opened by a button might be a cleaner solution.

Common Subform Problems

Subform shows all records instead of filtered records — Check your Link Master Fields and Link Child Fields. They are probably blank or pointing to the wrong fields.

Subform is blank — The link fields may not match. Ensure the data types of the link fields are identical in both tables.

Subform is too small — Resize the subform control on the main form. You can also set the subform's Auto Resize property to Yes.

Can't click into the subform — The subform control may be locked. Check the Locked property on the Data tab of the Property Sheet.

Conclusion

Subforms transform a flat data entry form into a rich, relational interface. Once you understand the link field concept, creating and customizing subforms becomes straightforward. Master this feature and you will be able to build professional Access applications that handle complex one-to-many data relationships elegantly.

Explore Topics

#subforms#forms#relationships#access design
M

Written by

MS Access Blog

Content creator and writer sharing insights and stories.