MS Access: Len Function
This MSAccess tutorial explains how to use the Access Len function with syntax and examples.
Description
The Microsoft Access Len function returns the length of the specified string.
Syntax
The syntax for the Len function in MS Access is:
Len ( text )
Parameters or Arguments
- text
- The string to return the length for.
Applies To
The Len 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 Len function in MS Access:
Len ("techonthenet") Result: 12 Len ("Wednesday") Result: 9 Len ("apple pie") Result: 9
Example in VBA Code
The Len function can be used in VBA code in Microsoft Access.
For example:
Dim LResult As Long LResult = Len ("www.techonthenet.com")
In this example, the variable called LResult would now contain the value 20.
Example in SQL/Queries
You can also use the Len function in a query in Microsoft Access.
For example:
In this query, we have used the Len function as follows:
Expr1: Len([CategoryName])
This query will return the length of 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:
NameLength: Len([CategoryName])
The results would now be displayed in a column called NameLength.
Advertisements