Others

How to Pass a Parent ID to a New Access Subform Record

John WilsonJohn Wilson Oct 28, 2026 868 views

Question details

The user needs to automatically populate the Parent ID when creating a new record in a child form or subform opened via a button.

How to Pass a Parent ID to a New Access Subform Record
Product
Microsoft Access
Device & OS
not provided
Scenario
Opening a child form from a main parent form to add new related records.
Observed behavior
Existing records display correctly, but the parent ID field remains blank when attempting to add a new record.
Before you start

Ensure you have the primary key (Parent ID) properly defined in your main table and a corresponding foreign key in your child table before attempting to link the forms.

Solution 1Recommended

Pass the Parent ID Using the OpenArgs Property in VBA

Best for opening a separate, large child form from a button on the parent form without embedding it.

When a child form is too large to fit as an embedded subform, you can open it as a separate popup. By utilizing the OpenArgs argument in the DoCmd.OpenForm method, you can seamlessly pass the current Parent ID to the newly opened form.

1
Modify the Parent Form Button

Open your main form in Design View. Right-click the button used to open the child form, select 'Build Event', and open the VBA editor for the On Click event.

2
Add the OpenForm Code

Enter the following code to pass the ID: DoCmd.OpenForm "ChildFormName", , , , , , Me.ParentIDControlName

3
Configure the Child Form

Open your child form in Design View. Go to the Property Sheet, select the 'Event' tab, and click the builder button (...) next to 'On Open'.

4
Set the Default Value via OpenArgs

In the VBA editor, add this code to assign the passed ID to new records: If Not IsNull(Me.OpenArgs) Then Me.ChildForeignIDControl.DefaultValue = """" & Me.OpenArgs & """"

Pass the Parent ID Using the OpenArgs Property in VBA
Syntax Formatting: The extra quotation marks around Me.OpenArgs ensure that the Default Value is treated as a literal string or properly formatted number, preventing type mismatch errors.
Free Microsoft Office alternative

Need a Lightweight Alternative for Your Daily Office Tasks?

While WPS Office does not include a direct database management equivalent to Microsoft Access, it offers a powerful, free, and highly compatible suite for your documents, spreadsheets, and presentations. Enjoy a familiar interface and seamless compatibility with Microsoft Word, Excel, and PowerPoint files without the heavy subscription costs.

  1. 1. Download the Installer: Visit the official WPS Office website and click the Free Download button.
  2. 2. Run the Installation: Open the downloaded executable file and follow the simple on-screen instructions.
  3. 3. Enjoy Free Office Tools: Launch WPS Office to easily open, edit, and save your Word, Excel, and PowerPoint documents.
Fully compatible with Microsoft Office formats including .docx, .xlsx, and .pptx.Lightweight installation with a user-friendly, familiar tabbed interface.Built-in PDF editing, merging, and conversion tools.Free to use for daily document processing and data analysis.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my subform's Parent ID blank when I add a new record?

This usually happens if the form is opened independently via a button without passing the parent record's ID, or if the Link Master Fields and Link Child Fields properties are not properly defined in an embedded subform control.

What is OpenArgs in Microsoft Access?

OpenArgs is a property used in the DoCmd.OpenForm method that allows you to pass a string expression (such as a Parent ID) from one form to another when the second form is opened.

Can I pass multiple values using OpenArgs?

Yes, but you must concatenate them into a single string separated by a delimiter (such as a pipe '|' or a comma). You can then use the Split function in the receiving form's VBA code to separate and assign the individual values.