totn Access Functions

MS Access: LTrim Function

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

Description

The Microsoft Access LTrim function removes leading spaces from a string.

Syntax

The syntax for the LTrim function in MS Access is:

LTrim ( text )

Parameters or Arguments

text
The string that you wish to remove leading spaces from.

Applies To

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

LTrim ("  Tech on the Net")
Result: "Tech on the Net"

LTrim (" Alphabet  ")
Result: "Alphabet  "

Example in VBA Code

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

For example:

Dim LResult As String

LResult = LTrim ("   Alphabet   ")

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

Example in SQL/Queries

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

For example:

Microsoft Access

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

Expr1: LTrim([CategoryName])

This query will return remove all leading spaces 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:

TrimmedName: LTrim([CategoryName])

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