How to Handle Null Department Values Using LIKE and IIF in Access Queries
Question details
The user needs an Access query to filter records based on a form field, ensuring that all records, including Null values, are returned when the form field is left blank.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Filtering database records dynamically based on user input from an Access form.
- Observed behavior
- The query must evaluate a form field to either filter by the entered text or bypass the filter entirely (displaying all records, including those with Null department fields) when the input is blank.
Verify the exact names of your tables, fields, and the corresponding form text boxes before updating your query criteria, as incorrect references will prompt parameter value errors.
Use an OR Condition with Is Null and Like Operators
Combine the 'Is Null' function with the 'Like' operator in the query criteria to successfully evaluate blank form fields and handle Null department values.
Using a standard IIF statement can sometimes fail to return Null values in the target field because Null does not equal an empty string. By using an OR statement that explicitly checks if the form field is null, you force Access to return true for all rows when no filter is applied.
In your Microsoft Access database, locate your query in the Navigation Pane, right-click it, and select 'Design View'.
Find the 'Criteria' row directly underneath the field you want to filter, such as the Department column.
Enter the following expression: ([Forms]![Your Form Name]![Your Text Box] Is Null) OR ([Your Table].[Department] Like "*" & [Forms]![Your Form Name]![Your Text Box] & "*"). Replace the placeholder names with your actual object names.
Carefully check that every opening parenthesis has a corresponding closing parenthesis to prevent syntax errors, then save and run the query.

Simplify Data Management with WPS Office Spreadsheets
While Microsoft Access is a complex tool for relational databases, many everyday data filtering, sorting, and reporting tasks can be completed much easier using spreadsheets. WPS Office is a free, lightweight suite that offers powerful data tools with full compatibility for your existing Office files.
- 1. Open Your Data in WPS: Launch WPS Spreadsheets and open your data file or export your Access table to an Excel format first.
- 2. Apply AutoFilter: Highlight your data headers, go to the 'Data' tab on the ribbon, and click 'AutoFilter'.
- 3. Filter for Blanks or Specific Data: Click the filter dropdown on your department column. You can search for specific text or check the '(Blanks)' option to easily view missing data.

Frequently Asked Questions
Why does my Access query exclude Null values when using the Like operator?
The 'Like' operator combined with wildcards (e.g., Like "*") matches any text string. However, Null is the absence of data, not a string. Therefore, wildcard searches naturally exclude records where the field is Null unless explicitly handled.
Can I use the IIF function to filter queries based on blank form fields?
Yes, but it can be tricky with Null values. An IIF expression like IIf(IsNull([Forms]![Form]![Field]), "*", [Forms]![Form]![Field]) works for populated fields, but using the OR condition with Is Null is generally more reliable for ensuring truly Null records are returned when the filter is bypassed.
How do I fix a parameter value prompt when running my query?
A parameter value prompt usually appears if Access cannot find the form or field referenced in your criteria. Ensure that the form is open when running the query and that the spelling of the form name and text box matches exactly.




