Auto fill leading zeros (1 Viewer)

ScottXe

Registered User.
Local time
Today, 16:26
Joined
Jul 22, 2012
Messages
123
I have an unbound control in data input form requiring to input a 6-digit number. I have put a validation rule restricting more than 6 digits. Most users prefer to enter, say 123 and the system can help enter the 3 leading zero for them. Any idea to accomplish it? Thanks!
 

ScottXe

Registered User.
Local time
Today, 16:26
Joined
Jul 22, 2012
Messages
123
Thanks for your advice. Unfortunately it is not applicable to my case. The unbound box is temporarily stored the input data and then twisted before passing onto the field control. I need to auto fill the leading zeros before the twisting.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:26
Joined
Sep 12, 2006
Messages
15,728
I would make a fixed width field of the sort you describe TEXT, rather than numeric. I cannot believe you will want to manipulate these values as numbers - so they are in fact text values, and stored with leading zeroes.

Someone else pointed out a simple trick to left fill leading spaces


usestring = right("000000") & enteredstring,6)

so "123"
becomes right("000000123",6)
becomes "000123"
 

ScottXe

Registered User.
Local time
Today, 16:26
Joined
Jul 22, 2012
Messages
123
I would make a fixed width field of the sort you describe TEXT, rather than numeric. I cannot believe you will want to manipulate these values as numbers - so they are in fact text values, and stored with leading zeroes.

Someone else pointed out a simple trick to left fill leading spaces


usestring = right("000000") & enteredstring,6)

so "123"
becomes right("000000123",6)
becomes "000123"

Hi Gemma,

The code is working well for my case. Thanks a lot!
 

Users who are viewing this thread

Top Bottom