Fix Microsoft Access DLookup Field and Control Reference Errors
Question details
Correct field names and form control references in Microsoft Access DLookup expressions.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A main form uses DLookup to retrieve information based on controls in a subform.
- Observed behavior
- Access reports that it cannot find a field when a DLookup expression contains an incorrectly quoted field name or an unqualified control reference.
Open the form's VBA code or control expression and identify the DLookup calls that fail. Check the names of the lookup table or query, its fields, and the subform control on the main form.
Correct DLookup field names and subform references
Use this method when Access cannot find a field or a control used by a DLookup expression.
In the VBA editor or expression containing DLookup, pass the field name as a string. For example, use DLookup("[btname]", "SO_Info_lookup", criteria), not DLookup([btname], "SO_Info_lookup", criteria).
In code running on the main form, refer to a subform control through the subform control's name, such as Me![SubformControl].Form![SerialFrom] or Me![SubformControl].Form![SOrder]. Replace SubformControl with the actual control name on the main form.
For a non-null text value from SOrder, build criteria such as "[SOrder] = '" & Replace(CStr(Me![SubformControl].Form![SOrder].Value), "'", "''") & "'". This doubles any apostrophes in the value. Use the actual lookup field name and a numeric criterion without text quotes if the field is numeric.
In the VBA editor or form property sheet, check every DLookup call for quoted field and domain names, brackets around names with special characters, and valid criteria. Run the form again and test the affected controls.

Work with spreadsheet lookup data in WPS Office
WPS Office is a free, lightweight alternative for spreadsheet and document work, with a familiar interface and support for common Microsoft Office formats. Open compatible files to move spreadsheet work into WPS; it does not run Access databases or fix Access DLookup code.

Frequently Asked Questions
Why does DLookup need quotation marks around the field name?
DLookup expects its expression and domain arguments as strings. In VBA, use DLookup("[btname]", "SO_Info_lookup", criteria) so Access receives the field name rather than evaluating [btname] as a reference first.
How do I reference a control on a subform from the main form?
In main-form VBA, use Me![SubformControl].Form![ControlName], replacing both names with the actual subform control and target control names. Check the subform control's Name property in Design View.
How can I use a text value containing an apostrophe in DLookup criteria?
Double apostrophes in the value before inserting it into a text criterion. In VBA, use Replace(value, "'", "''") and surround the resulting value with single quotes in the criteria string.
Can WPS Office run my Access DLookup expressions?
No. Access DLookup expressions and forms must be corrected in Microsoft Access. WPS Spreadsheets can work with compatible spreadsheet files and spreadsheet lookup functions instead.




