Access: Asc Function

In Access, the Asc function returns an integer representing the ANSI code corresponding to the first character in a string.

The syntax for the Asc function is:

Asc ( string )

The required string argument is any valid string expression. If the string contains no characters, a run-time error occurs. If more than one character is entered, the function will return the value for the first character and ignore all of the characters after the first.

Example

Asc ( "a" )     returns 97 
Asc ( "A" )     returns 65
Asc ( "apple" ) returns 97

VBA Code

Dim MyNumber 
MyNumber = Asc("A")

This example returns 65, the ANSI character code for an uppercase letter A. Now the MyNumber variable would contain the value 65.

SQL query

You can also use the Asc function in a query.

SELECT Asc('A') AS Expr1 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.