Access: Left Function

In Access, the Left function returns the leftmost n characters of a string.

The syntax for the Left function is:

Left ( string, length )

The argument string can be any string expression. However, if string contains Null, Null is returned. The argument length is a Long expression indicating how many characters to return. It must be between 0 and approximately 65,535, inclusive. If length is 0, the return value is a zero-length string. If length is greater than or equal to the number of characters in string, the entire string is returned. To find the number of characters in string, use Len(string).

Example

Left("WebCheatSheet",3)       returns "Web" 
Left("Articles", 15)                 returns "Articles"

VBA Code

Dim AnyString, MyStr 
AnyString = "Test string"
MyStr = Left(AnyString, 4)

This example uses the Left function to return a specified number of characters from the left side of a string. Now the MyStr variable would contain the value “test”.

SQL query

You can also use the Left function in a query.

SELECT Left([ItemDesired],3) AS Expr1 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.