How to Capitalize the Second Word in an MS Access SQL String
Question details
The user needs to convert only the second word of a multi-word string to uppercase while leaving the rest of the text in its original case format.

- Product
- MS Access SQL
- Device & OS
- not provided
- Scenario
- Formatting text fields in a database query where a specific word within a string must be targeted for capitalization.
- Observed behavior
- The text requires dynamic extraction and uppercase conversion of specifically the second word based on space delimiters.
Verify that your target text field consistently contains at least two words separated by standard spaces to prevent function errors when searching for the space delimiter.
Use Built-in MS Access SQL String Functions
Use a combination of Left, Mid, InStr, and UCase to isolate and capitalize the second word directly in your SQL query.
This method uses native MS Access SQL string functions to locate the first and second spaces. It preserves the text before the first space, applies the uppercase conversion to the extracted second word, and appends the remainder of the text.
Open your MS Access database and navigate to the Query Design view where you want to apply the formatting. Identify the exact name of the field containing your text.
In a new column of the query design grid, paste the following expression, replacing 'FieldName' with your actual field name: Left([FieldName], InStr(1, [FieldName], " ")) & UCase(Mid([FieldName], InStr(1, [FieldName], " ") + 1, InStr(InStr(1, [FieldName], " ") + 1, [FieldName], " ") - InStr(1, [FieldName], " ") - 1)) & Mid([FieldName], InStr(InStr(1, [FieldName], " ") + 1, [FieldName], " "))
Click the 'Run' button in the Query Design ribbon to execute the query and view the results with the second word capitalized.

Create a Custom VBA Function
Write a User-Defined Function (UDF) using the VBA Split function for a cleaner approach, which is especially useful for complex or highly variable strings.
Manage Your Data Effortlessly with WPS Office
While Microsoft Access handles complex SQL database queries, WPS Spreadsheet offers powerful, user-friendly text manipulation formulas for everyday data management without requiring SQL coding. Enjoy a lightweight, free alternative to Microsoft Office that easily handles text formatting.

Frequently Asked Questions
What happens if the string only contains one word?
If the string lacks a second word, the InStr function will not find a space, which will result in an 'Invalid Procedure Call' error. It is recommended to wrap the expression in an IIf() statement to check if InStr() > 0 before applying the formatting.
Can I capitalize the third word instead using this method?
Yes, you can adjust the InStr starting positions to locate the second and third spaces instead of the first and second, then apply UCase to the text extracted between those updated positions.
Is there a simpler way to do this in WPS Spreadsheet?
Yes, in WPS Spreadsheet you can use the Text to Columns feature to quickly split the text by spaces, capitalize the second column using the UPPER() function, and concatenate the text back together using the CONCATENATE() function or the '&' operator.




