Add proceeding zeros to zip less than 5 characters

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.
 
K

Klatuu

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")
 
J

Jim

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.
 
A

Akilah

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.
 
A

Akilah

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")
 

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

Similar Threads


Top