Reference Main Forms and Subforms in a Microsoft Access Order Form
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.

- 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.
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.
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.
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.
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.
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 Main Form from Subform Code
Use this approach when a button or other event on the search subform runs the code.
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.

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.




