Others

Fix DLookup #Error for Empty Fields in Microsoft Access

Khadija KhanKhadija Khan Nov 13, 2026 868 views

Question details

The user needs to prevent a Microsoft Access DLookup expression from returning #Error when the criteria field is empty or null.

Fix DLookup #Error for Empty Fields in Microsoft Access
Product
Microsoft Access
Device & OS
not provided
Scenario
A user has a DLookup expression in a Microsoft Access form or report and the criteria field can be left blank.
Observed behavior
The calculated control displays #Error when the criteria field is blank or null.
Before you start

Open the database object in Design view and identify the control containing the DLookup expression. Confirm whether the criteria field uses text or numeric data so you can choose the correct Nz replacement value.

Solution 1Recommended

Use Nz in the DLookup criteria expression to handle empty fields

Use this solution when the DLookup criteria field can be empty or null, and the expression currently returns #Error.

DLookup builds a SQL WHERE condition. If the criteria field is Null, the string concatenation can create an invalid expression, so Access displays #Error. Wrapping the field reference in Nz supplies a non-null default value and keeps the expression valid.

1
Open the form or report in Design View

In Microsoft Access, right-click the form or report that contains the DLookup expression and select Design View.

2
Select the calculated control

Click the text box or calculated control that shows #Error, then open the Property Sheet.

3
Edit the Control Source expression

In the Control Source property, update the DLookup criteria using Nz, for example: =DLookup("[LCS]","[LowestClassScore]","Subject=" & Nz([Forms]![Result Extended]![Subject],0)).

4
Match the Nz replacement value to the data type

If Subject is text, use Nz([Forms]![Result Extended]![Subject],"") and build the criteria as "Subject='" & Nz([Forms]![Result Extended]![Subject],"") & "'"; if it is numeric, use 0.

5
Switch to Form View and test

Save the form, switch to Form View, and clear the Subject field to confirm that the calculated control no longer displays #Error.

Use Nz in the DLookup criteria expression to handle empty fields
Choose the replacement value by data type: Use an empty string for text fields and 0 for numeric fields. Make sure the final criteria string includes quotes around text values.
Free Microsoft Office alternative

Use WPS Office Free as a Lightweight Microsoft Office Alternative

Because WPS Office does not include Microsoft Access or a DLookup function, this Microsoft Access expression issue must be corrected inside Access. For everyday documents, spreadsheets, and presentations, WPS Office is a free, lightweight alternative with full compatibility for Word, Excel, and PowerPoint files and a familiar ribbon interface.

  1. 1. Download the free installer: Go to the official WPS Office website and click Download WPS Office Free.
  2. 2. Install and launch WPS Office: Run the installer, complete the setup, and open WPS Office from the desktop or Start menu.
  3. 3. Open your existing files: Click Open in the WPS Office home screen and choose a .docx, .xlsx, or .pptx file to continue working.
Handles everyday Word, Excel, and PowerPoint tasks while Access database workarounds remain in Microsoft Access.Opens and saves Microsoft Office .docx, .xlsx, and .pptx files without conversion.Familiar ribbon UI reduces the learning curve when moving from Microsoft Office.Free to download and use with a lightweight installation and fast performance.
microsoft office alternative - wps office

Frequently Asked Questions

Why does DLookup return #Error when a criteria field is empty?

When the criteria field is Null, Access concatenates an invalid WHERE condition such as Subject=. Wrapping the field reference in Nz supplies a valid default value and prevents the error.

What Nz replacement value should I use in a DLookup text criteria?

Use an empty string with Nz and include quotes in the criteria string, for example: "Subject='" & Nz([Forms]![Result Extended]![Subject],"") & "'".

Can Nz be used with multiple DLookup criteria fields?

Yes, wrap each nullable field reference in Nz separately and choose a replacement value that matches each field's data type.

Does WPS Office support Microsoft Access DLookup expressions?

No, WPS Office does not include Microsoft Access or the DLookup function. This expression must be corrected in Microsoft Access; WPS Office is an alternative for Word, Excel, and PowerPoint files.

How do I test a DLookup expression after adding Nz?

Save the form or report, switch to Form View or Report View, and leave the criteria field blank to confirm the calculated control no longer displays #Error.