Advertisements

StrConv Function

Applies to: Access for Microsoft 365, Access 2019, Access 2016, Access 2013, Access 2010, Access 2007.

Returns a Variant (String) converted as specified.

Syntax

StrConv ( string, conversion [, LCID ] )

The StrConv function syntax has these arguments:

ArgumentDescription
stringRequired. String expression to be converted.
conversionRequired. Integer. The sum of values specifying the type of conversion to perform.
LCIDOptional. The LocaleID, if different than the system LocaleID. (The system LocaleID is the default.)

Settings

The conversionargument settings are:

ConstantValueDescription
vbUpperCase1Converts the string to uppercase characters.
vbLowerCase2Converts the string to lowercase characters.
vbProperCase3Converts the first letter of every word in string to uppercase.
vbWide *4*Converts narrow (single-byte) characters in string to wide (double-byte) characters.
vbNarrow *8*Converts wide (double-byte) characters in string to narrow (single-byte) characters.
vbKatakana **16**Converts Hiragana characters in string to Katakana characters.
vbHiragana **32**Converts Katakana characters in string to Hiragana characters.
vbUnicode64Converts the string to Unicode using the default code page of the system. (Not available on the Macintosh.)
vbFromUnicode128Converts the string from Unicode to the default code page of the system. (Not available on the Macintosh.)

*Applies to East Asia locales.

**Applies to Japan only.

Note: These constants are specified by Visual Basic for Applications (VBA). As a result, they may be used anywhere in your code in place of the actual values. Most can be combined, for example, vbUpperCase + vbWide, except when they are mutually exclusive, for example, vbUnicode + vbFromUnicode. The constants vbWidevbNarrowvbKatakana, and vbHiragana cause run-time errors when used in locales where they do not apply.

The following are valid word separators for proper casing: Null (Chr$(0)), horizontal tab (Chr$(9)), linefeed (Chr$(10)), vertical tab (Chr$(11)), form feed (Chr$(12)), carriage return (Chr$(13)), space (SBCS) (Chr$(32)). The actual value for a space varies by country/region for DBCS.

Remarks

When you’re converting from a Byte array in ANSI format to a string, you should use the StrConv function. When you’re converting from such an array in Unicode format, use an assignment statement.

Query examples

ExpressionResults
SELECT strConv(ProductDesc,1) AS Expr1 FROM ProductSales;Converts the values from “ProductDesc” field into uppercase and displays in column Expr1
SELECT strConv(ProductDesc,2) AS LowercaseID FROM ProductSales;Converts the values from “ProductDesc” field into lowercase and displays in column LowercaseID. Converts the first letter of every word from “ProductDesc” to uppercase and displays in column PropercaseID. All other characters are left as lowercase.

VBA example

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

This example uses the StrConv function to convert a Unicode string to an ANSI string.

Dim i As Long
Dim x() As Byte
x = StrConv("ABCDEFG", vbFromUnicode) ' Convert string.
For i = 0 To UBound(x)
Debug.Print x(i)
Next

See Also

String functions and how to use them

This information was compiled using information courtesy of © Microsoft 2020. All rights reserved.

Advertisements

Leave a Reply

%d bloggers like this: