How to Fix Microsoft Access InStr Query Errors and Crashes
Question details
Users need to resolve unexpected failures or application crashes when executing Microsoft Access queries that use the InStr function.

- Product
- Microsoft Access
- Device & OS
- Windows 10
- Scenario
- Running queries using the InStr function without explicitly specifying the optional starting position or comparison type arguments.
- Observed behavior
- Microsoft Access unexpectedly crashes or produces an error during query execution, even though the exact same InStr expression works perfectly in the VBA Immediate window.
Verify your current version of Microsoft Access by navigating to File > Account. Always ensure you have a recent backup of your database before modifying queries or repairing your Office installation.
Specify All Optional InStr Arguments Explicitly
Providing all four parameters, including the start position and comparison type, prevents the query engine from crashing.
In certain builds of Access for Microsoft 365, the query engine mishandles omitted optional arguments, resulting in an application crash. By manually supplying these default values, you can bypass the defect until a patch is released.
Launch your database, right-click the problematic query in the Navigation Pane, and select 'Design View'.
Find the field or criteria using the InStr function where optional arguments were omitted.
Modify the expression to include all four arguments: InStr([start], [string1], [string2], [compare]). For example, rewrite InStr([FieldName], 'SearchTerm') to InStr(1, [FieldName], 'SearchTerm', 1).
Click the Save icon, then switch to 'Datasheet View' to run the query and confirm the crash no longer occurs.

Compact and Repair the Database
Running the Compact and Repair tool can resolve underlying hidden corruption contributing to query execution failures.
Revert to an Earlier Office Build
If the issue is tied to a specific Microsoft 365 update, downgrading to a previous stable build can immediately restore functionality.
Discover WPS Office for a Seamless Productivity Experience
While Microsoft Access database issues require specific troubleshooting or updates, you can streamline your everyday document, spreadsheet, and presentation tasks with WPS Office. It provides a lightweight, free alternative to Microsoft Office that ensures high compatibility and reliable performance.
- 1. Visit the Official Website: Go to the official WPS Office website on your computer.
- 2. Download the Installer: Click the 'Free Download' button to get the latest installation package.
- 3. Install and Launch: Run the downloaded file, follow the installation prompts, and launch WPS Office to start creating.

Frequently Asked Questions
Why does the InStr function work in VBA but crash in an Access query?
In certain updates of Microsoft 365, a software defect causes the query engine to mishandle omitted optional arguments for the InStr function. The VBA compiler processes these optional parameters differently, which allows the VBA code to execute perfectly while the query fails.
What are the four arguments of the InStr function?
The full syntax is InStr([start], [string1], [string2], [compare]). 'Start' is the numeric starting position for the search, 'string1' is the text string being searched, 'string2' is the substring you want to find, and 'compare' sets the comparison type, such as binary (0) or textual (1).
How can I check my current Microsoft Access version?
Open Microsoft Access, click on 'File' in the top left corner, then select 'Account'. Under the 'Product Information' section on the right side, you will see your specific version and build number.
Will Microsoft release a permanent fix for this InStr query bug?
Yes, version-specific bugs causing application crashes are typically prioritized and addressed in subsequent Microsoft 365 updates. Ensure you monitor the Microsoft release notes and update your Office suite once a patch is rolled out.




