Syntax |
LEN(Text) |
Description |
Returns the number of characters in <Text>. |
Example |
LEN ("Personalized Printing") => 21 |
Text |
Any text expression or data field containing a text. |
You can use this function to calculate the length (the number of characters) of the database field. For example, certain ZIP codes or barcodes might need to have a specific number of characters to print correctly.
LEN is often used in combination with other functions, such as LEFT, RIGHT, MID and IF, where it can be used to determine exactly how many characters are printed of a selected database field.
In the following example, IF and LEN are combined to calculate the length of the "gender" database field. It also ensures that fields without text, but with spacing, are recognized and eventually the correct output is generated.
First Name |
Last Name |
Gender |
John |
Abrahams |
M |
Theresa |
Johnson |
F |
William |
Fremont |
M |
Tom |
Cooper |
|
IF(LEN([GENDER]) = 0, "Dear Sir, Madam", IF([GENDER] = "m", "Dear Mr." & [Name], "Dear Ms" & [Name] ) )
The result is:
Dear Mr John Abrahams
Dear Ms Theresa Johnson
Dear Mr William Fremont
Dear Sir, Madam