Search code examples
stringms-accessconcatenationiif

MS ACCESS- Trimming a Text and STR([Number]) Concatenation


I know the STR(expression) formula adds a space at the beginning of the field. When I use Trim during a concatenation, it does not remove the space. Anyone know why and how to fix it?

IIf(Len([Cust #])=1,Trim("00000" & Str([Cust #])),"")

result:

00000 2

Should be:

000002

Solution

  • Trim trims of spaces from beginning and end of a string, not from the middle. should be:

    IIf(Len([Cust #])=1,"00000" & Trim(Str([Cust #])),"")