Others

How to Prevent New Subform Records Based on a Main Form Value in Access

Emma BrownEmma Brown Nov 3, 2026 869 views

Question details

The user needs to restrict data entry in a Microsoft Access subform based on specific criteria or selected values present in the main parent form.

How to Prevent New Subform Records Based on a Main Form Value
Product
Microsoft Access
Device & OS
not provided
Scenario
Designing a relational database form where subform data entry needs conditional restrictions to enforce data integrity rules.
Observed behavior
Currently, the subform allows new records to be added indiscriminately, regardless of whether the main form's condition permits it.
Before you start

Ensure you have Design View permissions for both the main form and the subform in your Microsoft Access database, and back up your database before modifying form properties or adding VBA code.

Solution 1Recommended

Dynamically Toggle the AllowAdditions Property using VBA

Use a VBA event procedure to change the subform's AllowAdditions property to No when a specific condition on the main form is met.

This method is highly recommended because it prevents new record creation while still allowing users to view, edit, or delete existing records in the subform.

1
Open Form in Design View

Right-click your main form in the Access navigation pane and select 'Design View'.

2
Add Code to the Control's AfterUpdate Event

Select the control (e.g., a combo box) that determines the condition. In the Property Sheet, go to the Event tab, click the ellipsis (...) next to 'After Update', choose 'Code Builder', and write an If/Else statement to set Me.SubformName.Form.AllowAdditions = False when the condition is met.

3
Add Code to the Form's OnCurrent Event

To ensure the rule evaluates correctly when navigating between existing records, apply the exact same If/Else VBA logic to the main form's 'On Current' event.

4
Save and Test

Save your VBA module, switch the main form back to 'Form View', and test the behavior by changing the trigger value.

Dynamically Toggle the AllowAdditions Property using VBA
Verify Subform Control Name: Ensure you are using the name of the subform control container on the main form, not necessarily the name of the subform object itself in the navigation pane.
Free Microsoft Office alternative

Manage Your Data Effectively with WPS Office

While Microsoft Access is built for complex relational databases, many users find that advanced spreadsheets can handle their daily data tracking needs much more easily. WPS Office offers a powerful, lightweight, and completely free alternative to Microsoft Office.

  1. 1. Visit the WPS Website: Go to the official WPS Office website to access the free download.
  2. 2. Download the Installer: Click the download button to get the correct installation package for your Windows, Mac, or Linux system.
  3. 3. Install and Open: Run the installer, follow the simple on-screen instructions, and immediately start working with your existing Office files.
Fully compatible with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint (.pptx) formats.Advanced spreadsheet functionalities like Data Validation and PivotTables to easily control and analyze data entry.Lightweight design that runs smoothly on older devices without slowing down your system.Familiar, intuitive user interface that makes migrating from Microsoft Office completely seamless.
microsoft office alternative - wps office

Frequently Asked Questions

Can I restrict editing existing records in the subform instead of just additions?

Yes. You can set the subform's AllowEdits property to No using VBA (e.g., Me.SubformName.Form.AllowEdits = False). This will prevent users from modifying existing data while the main form condition is met.

Why is my VBA code not triggering when I change the main form value?

Ensure your code is placed in the 'AfterUpdate' event of the specific control you are interacting with, rather than the form's general update event. You must also include the code in the form's 'OnCurrent' event so it evaluates as you navigate through different records.

Does WPS Office include a database management tool like Microsoft Access?

WPS Office focuses on core productivity tools: Writer (Word), Spreadsheet (Excel), Presentation (PowerPoint), and PDF. While it does not include a direct Access clone, WPS Spreadsheet provides robust data validation and analysis tools that can efficiently handle most list-tracking and data management requirements.