Office Settings & Configuration

Populate a Microsoft Access Text Box from a Combo Box Selection

Chanuka GeekiyanageChanuka Geekiyanage Nov 13, 2026 868 views

Question details

Populate a price or other value in a Microsoft Access form text box when a user selects a product from a combo box.

Populate a Microsoft Access Text Box from a Combo Box Selection
Product
Microsoft Access
Device & OS
not provided
Scenario
An order-entry form needs to retrieve a product's price and, when appropriate, save that price with the order detail.
Observed behavior
The text box does not populate consistently. DLookup expressions can produce errors involving text criteria, numeric criteria, or Null values, and the combo box's update event sometimes does not respond.
Before you start

Open the form in Design View and check the combo box name, text box name, and product table's price field. The examples use cboProd, txtPrice, and a Products table with ProductID, ProductName, and Price fields; replace these with your actual names.

Solution 1Recommended

Copy the price from the combo box using its AfterUpdate event

Use the selected combo box row to populate the price directly, avoiding a separate DLookup expression and its criteria-formatting issues.

Include the price in the combo box's row source, even if that column is hidden. Access combo box Column indexes start at zero, so Column(2) reads the third column.

For order-entry applications, store the selected price in the order-detail record rather than recalculating historical orders from the current product price.

1
Include the price in the row source

In Design View, select cboProd and open its Property Sheet. On the Data tab, set Row Source Type to Table/Query and set Row Source to: SELECT ProductID, ProductName, Price FROM Products ORDER BY ProductName;

2
Configure the combo box columns

In the Property Sheet, set Column Count to 3 on the Format tab and Bound Column to 1 on the Data tab. To display only the product name, set Column Widths to 0";2";0" on the Format tab. The hidden third column still provides the price.

3
Create the AfterUpdate procedure

Select cboProd, open the Event tab in its Property Sheet, and set After Update to [Event Procedure]. Click the ellipsis button and choose Code Builder if prompted. Inside the generated cboProd_AfterUpdate procedure, enter: If IsNull(Me.cboProd) Then Me.txtPrice = Null Else Me.txtPrice = Me.cboProd.Column(2) End If

4
Bind the price for order-entry records

If the price must be saved with each order, select txtPrice and set Data > Control Source to the stored price field in the form's order-detail record source. Do not use a calculated expression as its Control Source. Keep the combo box bound to the order-detail product ID field.

5
Test a changed product selection

Save the form, switch to Form View, and select a different product in cboProd. Confirm that txtPrice shows the third-column value. For a bound order-entry form, move to another record and return to verify that the selected price was saved.

Copy the price from the combo box using its AfterUpdate event
Keep the column index aligned with the row source: Me.cboProd.Column(2) works only when the price is the third column. If you change the row source's column order, update the index. The Null branch also requires the destination field to allow Null; otherwise, validate the selection instead of assigning Null.
Free Microsoft Office alternative

Review exported Access product and price data in WPS Spreadsheets

WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility. Export Access tables or query results to Excel for an easy transition to spreadsheet review and reporting. WPS does not replace Access database forms or fix their VBA events.

Review exported product lists and order prices in WPS Spreadsheets.Open and edit Microsoft Excel .xlsx and .xls files.Use a familiar spreadsheet interface for filtering, calculations, and price reports.Move exported data into a lightweight Office suite without rebuilding your Access form.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Column(2) return the price instead of Column(3)?

Access combo box Column indexes are zero-based: Column(0) is the first column, Column(1) is the second, and Column(2) is the third. Check the field order under Property Sheet > Data > Row Source to identify the correct index.

Can I hide the price column and still read its value?

Yes. Include the price in the Row Source, set Column Count to include it, and set its width to zero under Property Sheet > Format > Column Widths. VBA can still read a hidden column with Me.cboProd.Column(index).

Why is the combo box's AfterUpdate code not running?

In Design View, select the combo box and check Property Sheet > Event > After Update. It should be set to [Event Procedure], with the code inside that control's event procedure. Test by changing the selection in Form View. Assigning the combo box value through VBA does not automatically trigger its AfterUpdate event.

Will this automatically fill the price when I open an existing record?

No. AfterUpdate runs when the user changes the combo box selection, not simply when a record opens. For order-entry records, bind txtPrice through Data > Control Source to the stored order-detail price so the saved value displays without being replaced by today's product price.

Should an old order use the product's current price?

Usually not. Bind the price text box to an order-detail price field and capture the price when the product is selected. This preserves the transaction price even if the product table's price changes later.