Preceding Zeros to text field.

G

Ghost

I have a text field used for Addresses. How do I add preceding zero the
field so that it will automatically populate it.

For example. 2345 Anywhere Street originally entered. What it to be
0002345 Anywhere Street.

Any assistance is greatly appreciated.
 
G

Guest

If the address string is always 7 digits long, you could use something like:

left("0000000", 7 - len ("1234")) & "1234"

If the total length of the final address string changes, you could use
something like this:

left (string (<total length of final address string>, "0"), <total length of
final address string> - len (<current, non-zero prefixed address string>)) &
<current, non-zero prefixed address string>

So for example, for 1234 Some St., and 7 total digits, you would have
left ("0000000", 7 - len("1234")) & "1234" ---> "0001234"

If final length was to be say 10 characters, you would have:
left (string(10, "0"), 10 - len( "1234")) & "1234" ---> "0000001234"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top