Access: Chr Function

In Access the Chr function returns the character associated with the specified ANSI code.

The syntax for the Chr function is:

Chr ( charcode )

The required charcode argument is the NUMBER used to retrieve the character. The argument charcode is an integer between 0 and 255, inclusive. Applications for Microsoft Windows use the ANSI character set. ANSI character codes in the range 0 to 31, inclusive, are the same as the standard, nonprintable ASCII codes. For example, Chr(13) returns a carriage-return character, and Chr(10) returns a linefeed character. Together they can be used to force a new line when message strings are formatted with MsgBox or InputBox.

Example

Chr( 65 )    returns "A" 
Chr( 97 )    returns "a"

VBA Code

Dim MyChar 
MyChar = Chr(100)

This example returns “d”, the character associated with the specified character code. Now the MyChar variable would contain the value “d”.

SQL query

You can also use the Chr function in a query.

SELECT Chr(37) AS Expr1, Chr(100) AS Expr2 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.