totn Access Functions

MS Access: Right Function

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

Description

The Microsoft Access Right function extracts a substring from a string starting from the right-most character.

Syntax

The syntax for the Right function in MS Access is:

Right ( text, number_of_characters )

Parameters or Arguments

text
The string that you wish to extract from.
number_of_characters
The number of characters that you wish to extract starting from the right-most character.

Applies To

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

Right ("Tech on the Net", 3)
Result: "Net"

Right ("Alphabet", 5)
Result: "habet"

Example in VBA Code

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

For example:

Dim LResult As String

LResult = Right ("Alphabet",3)

The variable LResult would now contain the value of "bet".

Example in SQL/Queries

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

For example:

Microsoft Access

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

Expr1: Right([CategoryName],10)

This query will return last 10 characters from the CategoryName field and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.

For example:

PartialName: Right([CategoryName],10)

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