How to Automatically Populate Form Fields Based on a Selection in Microsoft Access
Question details
The user needs a method to automatically fill dependent data-entry form fields based on a specific selection from a primary drop-down list or combo box.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Designing a data-entry form for medical outcome data where selecting a value like 'None' for the highest level of care should automatically set subsequent fields to 'No' or 0 to speed up data entry.
- Observed behavior
- The user currently has to manually enter data into dependent fields, and needs a way to automate this population based on the initial combo box selection.
Before adding automation code, ensure your database table fields have concise names without spaces or special characters (like <, >, or parentheses), as these complicate VBA programming.
Use the After Update Event with VBA Code
Attach a VBA procedure to the initial combo box's After Update event to detect the user's selection and instantly assign appropriate values to the dependent form controls.
In Microsoft Access, the After Update event is triggered immediately after a user makes a selection and moves out of a control. By attaching VBA code to this event, you can command Access to automatically fill in remaining fields. Note that storing calculated or heavily dependent values in a database table can sometimes conflict with relational database design principles; ensure that permanently storing these derived values is necessary for your workflow.
Right-click your data-entry form in the Access navigation pane and select 'Design View'.
Click on the initial combo box or drop-down list (e.g., 'Highest Level of Neonatal Care') that will trigger the changes.
Press F4 to open the Property Sheet. Go to the 'Event' tab and locate the 'After Update' property.
Click the ellipsis (...) button next to 'After Update' and select 'Code Builder' from the dialog box to open the VBA editor.
Write the VBA IF statement to evaluate the selection and set dependent fields. For example: `If Me.LevelOfCare = "None" Then Me.AdmittedWithin48 = False : Me.TimeInNICU = 0 End If`.
Save your VBA code, close the editor, switch your form back to 'Form View', and test the combo box to ensure the dependent fields update automatically.

Looking for a Lightweight Tool for Data Collection? Try WPS Office
While Microsoft Access is built for complex relational databases, many data tracking and collection tasks can be accomplished more easily with a robust spreadsheet application. WPS Office offers a free, highly compatible alternative to Microsoft Office, featuring powerful formulas and data validation tools to handle your everyday data entry needs without writing complex VBA code.
- 1. Download and Install: Download WPS Office Free from the official website and follow the quick installation process.
- 2. Open WPS Spreadsheet: Launch the application and create a new Spreadsheet, or open your existing .xlsx data tracking files.
- 3. Automate Data Entry: Use features like Data Validation for drop-down lists and IF formulas to automatically populate dependent cells instantly.

Frequently Asked Questions
What is the After Update event in Microsoft Access?
The After Update event is a control property that triggers a macro or VBA procedure exactly when the data inside a specific control (like a text box or combo box) is changed and the user moves to another field.
Why should I avoid spaces and special characters in database field names?
Spaces and special characters complicate programming and queries. In VBA or SQL, you must constantly wrap field names containing spaces or symbols in square brackets (e.g., [Field Name]). Using concise CamelCase naming (e.g., FieldName) prevents errors.
Is it bad practice to store dependent values in an Access table?
Often, yes. In relational database normalization, storing values that can be fully deduced or calculated from another field can lead to redundant data and anomalies. It is usually recommended to calculate these dependent values on-the-fly using queries or forms instead of storing them directly.




