Others

Fix an Access DLookup Expression Using a Combo Box Value

Bushra ParveenBushra Parveen Nov 22, 2026 869 views

Question details

Fix a DLookup expression that uses a combo box value to find a business ID.

Fix an Access DLookup Expression Using a Combo Box Value
Product
Microsoft Access
Device & OS
not provided
Scenario
A form uses a selected company name as the criterion for looking up BusinessID in the BusinessContacts table.
Observed behavior
The DLookup expression can return a type error when the text criterion is not correctly quoted.
Before you start

Open the Contacts form in Design View and check the combo box's Bound Column and Row Source properties. Confirm that CompanyName is a text field and that the table, field, form, and control names match those in your database.

Solution 1Recommended

Quote the Combo Box Text Value in DLookup

Use this approach when the combo box returns a company name and you need to retain the existing lookup.

The criterion passed to DLookup must contain quotation marks around the selected text value. Escaping apostrophes in the value prevents names such as O'Brien from breaking the criterion.

1
Open the control properties

Open the Contacts form in Design View, select the text box that should display BusinessID, and open its Property Sheet.

2
Enter the expression

On the Data tab, set Control Source to =DLookup("[BusinessID]","BusinessContacts","[CompanyName] = '" & Replace([Forms]![Contacts]![Combo63],"'","''") & "'"). Adjust the names if your database uses different ones.

3
Test a selection

Switch to Form View, select a company in Combo63, and check that the text box displays the matching BusinessID.

Quote the Combo Box Text Value in DLookup
Check the bound value: This expression assumes Combo63 returns company name text. If its bound value is a numeric BusinessID, use the combo box value directly instead.
Free Microsoft Office alternative

Work With Office Files in WPS Office

WPS Office is a free, lightweight alternative for documents, spreadsheets, and presentations, with a familiar interface and Office format support for easier migration. It does not fix Access DLookup expressions or replace an Access database.

Open and edit Microsoft Office formats such as DOCX, XLSX, and PPTXUse a familiar interface to move between documents, spreadsheets, and presentationsWork with tabular data in WPS Spreadsheet alongside your Access workflowChoose a free, lightweight suite for everyday Office file tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does my DLookup expression produce a type error?

A text criterion needs quotation marks around the selected value. Check that CompanyName is a text field and that the combo box's bound column returns a company name rather than a numeric ID.

How do I handle a company name containing an apostrophe?

Use Replace([Forms]![Contacts]![Combo63],"'","''") when building the quoted criterion. This doubles apostrophes in the selected value so Access can interpret them as text.

Can I get BusinessID without using DLookup?

Yes. Include BusinessID and CompanyName in the combo box's Row Source, set Bound Column to 1, and hide the ID column with Column Widths. Another control can then use =[Combo63] as its Control Source.

What if more than one company has the same name?

DLookup returns a matching value, but a company name may not uniquely identify a record. Bind the combo box to the unique BusinessID instead so the selected record supplies its ID directly.