Fix a Missing Operator in a Microsoft Access DLookup Query
Question details
Fix a DLookup criteria expression that causes a missing operator error when comparing a text ID.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A VBA DLookup expression searches an Equipment table using an ID value that contains text.
- Observed behavior
- Access interprets an unquoted value such as Soldering System as part of the query expression and reports a missing operator.
In Access, open the Equipment table in Design View and check the data type of the ID field. Also confirm that the value in rs!EquipmentType is the value you intend to compare with ID.
Quote and escape text criteria in DLookup
Use this approach when the ID field stores text, including values with spaces or apostrophes.
Open the relevant module or form code in the VBA editor and locate the DLookup call that searches the Equipment table.
Wrap the text value in single quotes and escape embedded apostrophes: DLookup("[EquipmentType]", "Equipment", "[ID]='" & Replace(rs!EquipmentType, "'", "''") & "'").
Run the code with a matching ID such as Soldering System, then test a value containing an apostrophe. Confirm that DLookup returns the expected EquipmentType.

Use unquoted criteria for a numeric ID
Use numeric criteria instead if the Equipment table's ID field is a number rather than text.
Work with Office documents using WPS Office
WPS Office is a free, lightweight alternative for working with documents, spreadsheets, and presentations. Its familiar interface and Microsoft Office format compatibility make it easier to move everyday files. It does not fix Access VBA or replace an Access database.

Frequently Asked Questions
Why does DLookup report a missing operator for a text value?
Access expects a text value in the criteria expression to be enclosed in quotes. Without them, a value such as Soldering System is parsed as part of the expression rather than as a text literal.
How do I handle an apostrophe in the lookup value?
When using single quotes around a text criterion, use Replace(value, "'", "''") to double any embedded apostrophes before concatenating the value into the DLookup criteria.
Should a numeric ID be enclosed in quotes?
No. If ID is a numeric field, validate the source value and concatenate it without text quotes, such as "[ID]=" & CLng(idValue) for a valid integer within the Long range.
What does DLookup return if no record matches?
DLookup returns Null when no record satisfies the criteria. Check the result with IsNull before using it, and verify that the source value matches the field being searched.




