Others

Reference Main Forms and Subforms in a Microsoft Access Order Form

Steven ParkerSteven Parker Nov 14, 2026 868 views

Question details

Reference the order ID on an Access main form and the item ID on a search subform without confusing controls that share the same name.

Reference Main Forms and Subforms in a Microsoft Access Order Form
Product
Microsoft Access
Device & OS
not provided
Scenario
An order form uses a main form for the order record and a search subform for the item record.
Observed behavior
Me refers to the form containing the running code, so Me.ID may refer to a different control depending on where the code runs.
Before you start

Open the order form in Design View and use the Property Sheet to check the names of the main form, the subform control, and the ID controls. The subform control name can differ from the name of the form it displays.

Solution 1Recommended

Reference the Subform from the Main Form

Use this approach when your VBA code runs on the main order form and needs the current item ID from the search subform.

1
Check the subform control name

In Design View, select the subform container on the main form and open Property Sheet > Other. Check its Name property; the example below uses subfrmSearchListORDER.

2
Open the main form event code

Select the main form button that saves the order, open Property Sheet > Event, and choose the builder next to On Click to open its VBA event procedure.

3
Reference both ID controls

In the event procedure, use the form hierarchy to read the controls: rs.Fields("OrderID") = Forms!NewOrderForm!ID.Value and rs.Fields("ItemID") = Forms!NewOrderForm!subfrmSearchListORDER.Form!ID.Value. Replace the names with those from your Property Sheet and use an existing updatable recordset named rs.

Reference the Subform from the Main Form
Use the subform control name: The name after the main form must be the subform control's Name property, not necessarily the name of its Source Object. The main form must be open, and the item reference reads the control on the subform's current record.
Free Microsoft Office alternative

Use WPS Office for Related Order Documents and Spreadsheets

WPS Office is a free, lightweight alternative for working with order spreadsheets and documents. Its familiar interface and Microsoft Office format support make it easy to move compatible files between suites. Microsoft Access is still required for Access forms and their VBA code.

Organize order and item information in WPS Spreadsheets.Open and edit compatible Microsoft Excel XLSX, Word DOCX, and PowerPoint PPTX files.Use a familiar interface for common office tasks.Work with a free, lightweight office suite.
QA img-9

Frequently Asked Questions

Why doesn't Forms!subfrmSearchListORDER!ID work?

A form embedded as a subform is normally reached through its open main form and the subform control's Form property. For example, use Forms!NewOrderForm!subfrmSearchListORDER.Form!ID.Value, replacing the names with your own.

How do I find the subform control name?

Open the main form in Design View, select the subform container, and check Property Sheet > Other > Name. This name may differ from the form named in the Source Object property.

What does Me.ID refer to in Access VBA?

Me refers to the form whose module contains the running code. Me.ID therefore refers to the ID control on that form, whether it is the main form or the subform.

Do I have to rename controls that are both called ID?

No. Fully qualified references can distinguish them, such as Me.Parent!ID and Me!ID in subform code. Descriptive names such as txtOrderID and txtItemID can make the code easier to read.

Can WPS Office run my Access order form?

No. WPS Office can work with compatible spreadsheets and documents, but it does not run Microsoft Access forms or their VBA code. Use Microsoft Access to maintain the order form.