Add proceeding zeros to zip less than 5 characters

  • Thread starter Thread starter Akilah
  • Start date Start date
A

Akilah

Hi, is there a way to add proceeding zeros to zip code text field that is
less than 5 characters? I want a way to add the zeros to the field to make
the length 5 characters. For instance, it the zip code is 1234, make if
012345. or if it's 123, make it 00123. Thanks in advance.
 
If you have to add zeros to it, it isn't a text field. A text field will
retain leading zeros because it sees the numbers as text characters. You
have a numeric field. Personally, I would make it a text field. But, to
display the numeric version with leading zeros, use the Format property of
the control where you display it.
"00000" or where necessary, Format(zip, "00000")
 
I've used a similar fix and it works well, but how did the leading zeros get
truncated in the first place?

It happens regularly with importing data from spreadsheets, even if the
spreadsheet format is text and the import field is text. Is there a way to
prevent this from happening? I've searched, but never found a simple
solution other than to fix it afterwards with an update query as you
suggest.

Peace,
Jim


RonaldoOneNil said:
Right("00000" & [ZipCode],5)

Akilah said:
Hi, is there a way to add proceeding zeros to zip code text field that is
less than 5 characters? I want a way to add the zeros to the field to
make
the length 5 characters. For instance, it the zip code is 1234, make if
012345. or if it's 123, make it 00123. Thanks in advance.
 
Thanks.

RonaldoOneNil said:
Right("00000" & [ZipCode],5)

Akilah said:
Hi, is there a way to add proceeding zeros to zip code text field that is
less than 5 characters? I want a way to add the zeros to the field to make
the length 5 characters. For instance, it the zip code is 1234, make if
012345. or if it's 123, make it 00123. Thanks in advance.
 
Thanks.
Klatuu said:
If you have to add zeros to it, it isn't a text field. A text field will
retain leading zeros because it sees the numbers as text characters. You
have a numeric field. Personally, I would make it a text field. But, to
display the numeric version with leading zeros, use the Format property of
the control where you display it.
"00000" or where necessary, Format(zip, "00000")
 
Back
Top