Adding leading zeros to alphanumeric field (1 Viewer)

mathsbeauty

Registered User.
Local time
Today, 20:57
Joined
Apr 14, 2011
Messages
13
Hello! I am new here. If "2 FF" is in some field, I want display in report as "02 FF". If "23 FF" is in some field , I want display in report as "23 FF" i.e. if there is only one digit on the left, then I want to add one leading zero to make it two digit. Please note that there is space before FF. I hope to get some help from experts.
 
Sorry Dear, but it doesn't work. It just displays 00 only.
 
How have you coded it in your project.
 
iif(len(trim([ExistingField]))=4,"0"&[ExistingField],[ExistingField])

i.e. if existing string length is just 4 characters (including one space), then precede the text with "0" else leave as it is ...

this assumes of course that the string length is either 4 or 5
 
My solution adds 00 and the 2 FF together to get 002 FF it then returns the right 5 characters giving 02 FF.

If is was 23 FF 0023 FF would still return 23 FF
 
Thanks David, for your efforts. I just coded it as =Right("00" & OldField,5) in a text box in report. Anyway I got the solution from Paul0 as posted in thread.Thanks once again.
 
Thanks Paul0, for your efforts. It just worked perfectly! Thank you very much!
 
You're welcome ...

ps David's solution is pretty neat too
 

Users who are viewing this thread

Back
Top Bottom