totn Access Functions

MS Access: Asc Function

This MSAccess tutorial explains how to use the Access Asc function with syntax and examples.

Description

The Microsoft Access Asc function returns the NUMBER code that represents the specific character.

Syntax

The syntax for the Asc function in MS Access is:

Asc ( string )

Parameters or Arguments

string
The specified character to retrieve the NUMBER code for. 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.

Applies To

The Asc 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 Asc function in MS Access:

Asc ("W")
Result: 87

Asc ("Wednesday")
Result: 87

Asc ("x")
Result: 120

Example in VBA Code

The Asc function can be used in VBA code in Microsoft Access.

For example:

Dim LResult As Integer

LResult = Asc ("W")

In this example, the variable called LResult would now contain the value 87.

Example in SQL/Queries

You can also use the Asc function in a query in Microsoft Access.

For example:

Microsoft Access

In this query, we have used the Asc function as follows:

Expr1: Asc("x")

This query will return the NUMBER code for "x" and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.

For example:

AscValue: Asc("x")

The results would now be displayed in a column called AscValue.

View a listing of the ascii values.