How can I preserve leading zeros?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My company's identification numbers--employee number, client number, project
number, etc.--have specific lengths. If my employee number is 364, it has to
be shown as 00364, or it will be thrown out as invalid. Several numbers in
my tables (and data entry forms) are formatted this way, but every time I
type in the leading zeros, they're deleted automatically when displayed. It
makes no difference if it's text or a number. I even found the place to
create my own input mask, and I thought that that would do it, but it didn't.
Please help!
 
If they're text, they shouldn't lose the leading zeroes unless you're doing
something to make them disappear.
 
If you format the cell by selecting "Custom" in the "Category:" list of the
Format Cells (Number tab) and then key in the number of leading zeros you
could have (00 in your example) into the "Type:" box and click the "OK"
button it will perserve your leading zeros.
 
I need to add a stipulation I left out of my original request. The number of
leading zeros is dependent upon the length of the field and the length of the
number to put in it. If an employee number is 5 digits long, I'll need no
leading zeros. If an employee number is 3 digits long, I'll need 2 leading
zeros. Same for a 15-digit project number: if the number is 4 digits long,
I need 11 leading zeros; if 5 digits long, 10 leading zeros. The responses
I've been given are excellent, but they do not cover this particular quirk.
 
If you're formatting the field, you put as many 0s in the Format as you
need.

If you're trying to change the value, you can use something like: Value =
Right(String(n, "0") & Value), n)

where n is the number of digits you want.
 
or
format(thefield,"00000")

pieter

Douglas J. Steele said:
If you're formatting the field, you put as many 0s in the Format as you
need.

If you're trying to change the value, you can use something like: Value =
Right(String(n, "0") & Value), n)

where n is the number of digits you want.
 

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

Back
Top