Fix Optional Wildcard Search Parameters in Microsoft Access
Question details
Create an Access search query that accepts any combination of optional criteria, including partial text.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A search form needs to filter records by one, several, or all available criteria.
- Observed behavior
- The desired query should find text containing a term such as "hip" and ignore criteria left blank.
Identify the table fields and search form controls you want to use. Check whether the database uses ANSI-89 wildcards, such as *, or ANSI-92 wildcards, such as %.
Use a separate optional condition for each Access query parameter
Use this approach when users need to combine partial text and exact-match filters or leave any filter blank.
In Access, open the search query in Design View, then select View > SQL View. Replace the table and field names in the following example with your own.
Use a WHERE clause such as: SELECT * FROM [YourTable] WHERE ([TextField] LIKE "*" & [Search text] & "*" OR [Search text] IS NULL) AND ([StatusField] = [Status] OR [Status] IS NULL);
To use an open search form instead of parameter prompts, replace each occurrence of a parameter with its control reference, such as [Forms]![SearchForm]![SearchText]. Use the same reference in both parts of that condition.
Run the query from the open form or select Run in Query Design. Test "hip", an exact status, both criteria together, and blank criteria. Confirm that an empty control supplies Null.

Add independent optional start and end date filters
Use separate date conditions when users may enter only a start date, only an end date, or both.
Use an AutoExpand combo box for known search values
Use a combo box instead of a contains search when users can select from a known list of values.
Work with exported Access data in WPS Office
WPS Office is a free, lightweight alternative for working with Office documents. Export Access data to an Excel workbook and open it in the familiar WPS Spreadsheets interface for a straightforward move to spreadsheet-based work. WPS does not run Access queries or fix Access forms.

Frequently Asked Questions
Why does each optional condition need parentheses?
Parentheses keep each match test together with its IS NULL alternative. Join the parenthesized conditions with AND so each criterion is evaluated independently.
How do I find records containing the word "hip"?
In an ANSI-89 Access query, use a condition such as [TextField] LIKE "*" & [Search text] & "*" and enter hip for the parameter. This also matches longer text containing those letters.
Why does Access still prompt for a parameter when I use a form?
Check the spelling of the reference in SQL View, including the form and control names, and make sure the form is open. A reference such as [Forms]![SearchForm]![SearchText] must match the actual names.
Can I leave just one date limit blank?
Yes. Test the start and end parameters independently with IS NULL conditions. This allows either limit to be omitted without relying on BETWEEN.
What happens when every search criterion is blank?
If every optional control supplies Null, each IS NULL alternative is true, so the query returns all records unless another condition restricts them.




