How to Remove Everything After an Ampersand in Microsoft Access
Question details
The user wants to remove an ampersand (&) and all subsequent characters from a specific text field in a database table, while keeping records without an ampersand completely intact.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Cleaning and standardizing text data across records within a database table.
- Observed behavior
- Target records containing an ampersand need to be truncated to keep only the preceding text and trimmed of extra spaces, without returning errors on non-matching records.
Always create a backup copy of your database table and test your logic with a Select query before running any Update query to prevent accidental data loss.
Use an Update Query with InStr and Trim Functions
This is the most reliable method to locate the first ampersand, extract the preceding text, and remove trailing spaces directly using the query design grid.
By combining the Left and InStr functions, you can dynamically calculate the length of the string before the ampersand. The Trim function then ensures no trailing spaces are left behind.
Open your database in Microsoft Access, navigate to the Create tab on the ribbon, and select 'Query Design'.
Add the table containing the target text field (e.g., ODOS) to the query grid.
Click the 'Update' button in the Query Type group on the ribbon to convert your standard select query into an Update Query.
In the Criteria row under your target field, type `Like "*&*"`. This ensures the query only attempts to modify records that actually contain an ampersand.
In the Update To row, enter the following expression: `Trim(Left([YourFieldName], InStr([YourFieldName], "&") - 1))` (replace 'YourFieldName' with your actual field name).
Click the 'Run' button (the red exclamation mark) on the ribbon to execute the update query and apply the changes to your table.

Use the Split Function in VBA
If you are processing data programmatically through VBA rather than a direct query grid, the Split function offers a simple array-based approach.
Looking for a Lightweight and Powerful Office Suite?
While Microsoft Access handles complex relational databases, WPS Office provides a free, lightweight, and incredibly intuitive alternative for managing your spreadsheets, documents, and presentations. Enjoy seamless compatibility with Microsoft Excel, Word, and PowerPoint formats without the heavy subscription fees.
- 1. Visit the WPS Office Website: Navigate to the official WPS Office website to find the correct installation package for your operating system.
- 2. Download and Install: Click the 'Download WPS Office Free' button and run the lightweight installer.
- 3. Open Your Files Instantly: Launch WPS Office and open your existing Office documents with full compatibility and zero formatting loss.

Frequently Asked Questions
Why do I get an 'Invalid procedure call' error when running the update query?
This error usually happens if the query attempts to process a record that does not contain an ampersand. Because the ampersand is missing, the `InStr` function returns 0. Subtracting 1 results in -1, causing the `Left` function to fail. Ensure you have added the criteria `Like "*&*"` to prevent this.
What is the difference between InStr and InStrRev in Access?
The `InStr` function searches for your specified character (the ampersand) starting from the beginning (left side) of the text string. Conversely, `InStrRev` searches starting from the end (right side). If your text contains multiple ampersands, `InStr` will split at the first occurrence, while `InStrRev` will split at the last.
Can I use the Split function directly in an Access Update query grid?
No, the `Split` function is strictly available in VBA (Visual Basic for Applications). If you attempt to enter it directly into the 'Update To' row of a Query Design grid, Access will not recognize it and will return an error. You must use the `Left` and `InStr` combination for query grids.




