MS Access: StrConv Function
This MSAccess tutorial explains how to use the Access StrConv function with syntax and examples.
Description
The Microsoft Access StrConv function returns a string converted as specified.
Syntax
The syntax for the StrConv function in MS Access is:
StrConv ( text, conversion, LCID )
Parameters or Arguments
- text
- The string that you wish to convert.
- conversion
The type of conversion to perform. The following is a list of valid parameters for conversion.
Parameter Value Description vbUpperCase 1 Converts the string to all uppercase. vbLowerCase 2 Converts the string to all lowercase. vbProperCase 3 Converts the first letter to every word to uppercase. All other characters are left as lowercase. This option is similar to the InitCap function in Oracle. vbUnicode 64 Converts the string to Unicode. vbFromUnicode 128 Converts the string from Unicode to the default code page of the system. TIP: If you are using the StrConv function in VBA code, you can use the vb parameter listed in the table above. If you are using this function in a query, you will have to use the numeric value.- LCID
- Optional. If this parameter is omitted, the StrConv function assumes the system LocaleID.
Applies To
The StrConv function can be used in the following versions of Microsoft Access:
- Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000
Example
Let's look at how to use the StrConv function in MS Access:
StrConv ("tech on the net", 1) Result: "TECH ON THE NET" StrConv ("TECH ON THE NET", 2) Result: "tech on the net" StrConv ("TECH ON THE NET", 3) Result: "Tech On The Net"
Example in VBA Code
The StrConv function can be used in VBA code in Microsoft Access.
For example:
Dim LResult As String LResult = StrConv ("TECH ON THE NET", 3)
In this example, the variable called LResult would now contain the value "Tech On The Net".
Since we are using the StrConv function in VBA, we could also use the vb values for the conversion parameter, such as:
Dim LResult As String LResult = StrConv ("TECH ON THE NET", vbProperCase)
In this example, the variable LResult would also contain the value "Tech On The Net".
Example in SQL/Queries
You can also use the StrConv function in a query in Microsoft Access.
For example:
In this query, we have used the StrConv function as follows:
Expr1: StrConv([CategoryName],3)
This query will convert the CategoryName field to proper case and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.
For example:
PropercaseName: StrConv([CategoryName],3)
The results would now be displayed in a column called PropercaseName.
Advertisements