Show an Access Subform Based on a Form Field Value
Question details
Show the appropriate detail subform on an Access main form based on the current record's 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.
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.
Update subform visibility in the main form's Current event
Use this approach to select the correct subform whenever the current record changes.
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.
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")
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.
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.

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.

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.




