Others

Show an Access Subform Based on a Form Field Value

Anum MushtaqAnum Mushtaq Nov 25, 2026 868 views

Question details

Show the appropriate detail subform on an Access main form based on the current record's field value.

Show an Access Subform Based on a Form Field Value
Product
Microsoft Access
Device & OS
not provided
Scenario
A main form has different detail subforms for field values such as A, B, and C.
Observed behavior
Code in the Load event may run only once, so the visible subform does not update when the user navigates to another record.
Before you start

Open the main form in Design View and identify the controlling field and each subform control name in the Property Sheet. The control name may differ from the name of the form displayed inside it.

Solution 1Recommended

Update subform visibility in the main form's Current event

Use this approach to select the correct subform whenever the current record changes.

1
Open the Current event

In Design View, select the main form, open Property Sheet > Event, and choose [Event Procedure] next to On Current. Click the ellipsis button to open the VBA editor.

2
Set the visibility rules

Add the following code inside Form_Current, replacing ModelType and the three subform control names with your own names: Me!frmModelADetails.Visible = (Nz(Me!ModelType, "") = "A") Me!frmModelBDetails.Visible = (Nz(Me!ModelType, "") = "B") Me!frmModelCDetails.Visible = (Nz(Me!ModelType, "") = "C")

3
Refresh after an edit

If users can change the controlling value on the form, select its control in Design View and open Property Sheet > Event > After Update. Choose [Event Procedure], click the ellipsis, and call Form_Current from the event procedure.

4
Test the form

Save the form, switch to Form View, and use the record navigation buttons to move between records with A, B, and C values. If the field is editable, change its value and confirm that the visible subform switches.

Update subform visibility in the main form's Current event
Check control names and unmatched values: The code refers to subform controls on the main form, not necessarily their source form names. With these rules, all three controls are hidden if the field is blank or does not match A, B, or C.
Free Microsoft Office alternative

Use WPS Office for Related Documents and Spreadsheets

WPS Office is a free, lightweight, easy-to-use alternative for everyday documents and spreadsheets, with a familiar interface and Microsoft Office format compatibility for an easier transition. It does not fix Microsoft Access form events or replace Access subform functionality.

Review related tabular data in WPS SpreadsheetsOpen and edit Microsoft Excel XLSX and Word DOCX filesUse a familiar interface for common office tasksWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't the subform change when I navigate to another record?

The main form's Load event runs when the form loads, not each time you navigate. Put the visibility rules in Property Sheet > Event > On Current instead.

How do I find the subform control name?

Open the main form in Design View, select the subform control, and check its Name property in the Property Sheet. This name can differ from the source form's name.

Will the Current event update the subform as soon as I edit the field?

Not necessarily. Add an After Update event procedure to the controlling field's form control and call Form_Current so visibility refreshes after the edit.

What happens if the controlling field is blank?

In the example, Nz treats a Null value as an empty string. Because it does not match A, B, or C, all three subform controls are hidden.