Use Optional Form Criteria in a Microsoft Access Query
Question details
Create an Access query that applies form criteria only when the corresponding controls contain values.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A query uses form controls as optional exact-match and range filters.
- Observed behavior
- The query returns no records when optional controls contain values, and Access rearranges complex OR and Is Null criteria in Design view.
Open the form used by the query and check the names of its controls and the fields they filter. Confirm that the control values match the data types of the corresponding fields.
Write optional form criteria in Access SQL view
Use a separate OR condition for each optional control so that a null control does not restrict the results.
Access Design view can rearrange complex criteria, making them difficult to read and maintain. Writing the conditions in SQL view makes the intended grouping clearer.
The example uses an exact-match control and two optional numeric range controls. Replace the table, field, form, and control names with those in your database.
In Access, open the query, then choose View > SQL View. Start with a query that returns the required records before adding optional criteria.
In the WHERE clause, add a condition such as ([SomeField] = Forms![SomeForm]![SomeControl] OR Forms![SomeForm]![SomeControl] IS NULL). The field is filtered when the control has a value and unrestricted when it is Null.
Join each additional condition with AND. For a numeric range, use ([Amount] >= Forms![SomeForm]![MinAmount] OR Forms![SomeForm]![MinAmount] IS NULL) AND ([Amount] <= Forms![SomeForm]![MaxAmount] OR Forms![SomeForm]![MaxAmount] IS NULL).
Save the query from SQL view, leave the form open, and select Run. Test with all controls empty, each control populated individually, and multiple controls populated together.

Work with Office spreadsheets in WPS Office
WPS Office is a free, lightweight alternative for working with documents and spreadsheets in a familiar interface. Its Office format compatibility helps you move existing files into WPS, although it does not fix Microsoft Access queries or replace Access forms.

Frequently Asked Questions
Why does Access rearrange my query criteria?
Access may display complex OR conditions across multiple rows in Design view. Open the query with View > SQL View to inspect the grouped conditions more easily.
Why does Access ask me to enter a parameter value?
Check that the referenced form is open and that the form and control names in Forms![FormName]![ControlName] are spelled correctly. A misspelled field name can also trigger a parameter prompt.
Can I leave only one end of a range blank?
Yes. Use separate conditions for the minimum and maximum controls, each with its own OR control IS NULL test. A blank minimum then leaves only the maximum restriction, and vice versa.
Should each imported worksheet have its own Access table?
Usually, related records belong in a shared table, with columns identifying their source or category. Review the database structure before adding more queries or aggregations; separate tables for each worksheet can make filtering and maintenance harder.




