Others

Use Optional Form Criteria in a Microsoft Access Query

Anum MushtaqAnum Mushtaq Nov 25, 2026 868 views

Question details

Create an Access query that applies form criteria only when the corresponding controls contain values.

Use Optional Form Criteria in a Microsoft Access Query
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.
Before you start

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.

Solution 1Recommended

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.

1
Open SQL view

In Access, open the query, then choose View > SQL View. Start with a query that returns the required records before adding optional criteria.

2
Add an exact-match condition

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.

3
Add optional range conditions

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).

4
Save and test the query

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.

Write optional form criteria in Access SQL view
Check empty text controls: The IS NULL test handles Null values, not zero-length strings. If a text control can contain an empty string, account for that separately or ensure it returns Null when cleared.
Free Microsoft Office alternative

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.

Review and organize spreadsheet data in WPS SpreadsheetsOpen and edit Microsoft Excel XLS and XLSX filesUse a familiar interface for everyday Office tasksGet a free, lightweight suite for documents and spreadsheets
microsoft office alternative - wps office

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.