Format Zip Code

A

Andy

Hi;

Need help formating Zip Codes.

Tried these answers:
Format([txtZip],"00000-0000")
And
Format([txtZip],"#####-####")

Worked great when the Zip contained 9 digits: 12345-6789

Not correct when 5 digits:
Returns 12345-0000 or 12345-####

Anyone over come this?

Andy
 
F

fredg

Hi;

Need help formating Zip Codes.

Tried these answers:
Format([txtZip],"00000-0000")
And
Format([txtZip],"#####-####")

Worked great when the Zip contained 9 digits: 12345-6789

Not correct when 5 digits:
Returns 12345-0000 or 12345-####

Anyone over come this?

Andy

If the hyphen is not being stored with the Zip code:
123456789 or 12345

=IIf(Len([ZIP]>5,Left([ZIP],5) & "-" & Right([ZIP],4),[ZIP])

If the hyphen is stored with the Zip code:
12345-6789 or 12345-

=IIf(Len([ZIP]>6,[ZIP],Left([ZIP],5))
 
A

Andy

Fred;

Thank You.

How simple when somebody shows you how to do it.

Thank You again.

Andy


fredg said:
Hi;

Need help formating Zip Codes.

Tried these answers:
Format([txtZip],"00000-0000")
And
Format([txtZip],"#####-####")

Worked great when the Zip contained 9 digits: 12345-6789

Not correct when 5 digits:
Returns 12345-0000 or 12345-####

Anyone over come this?

Andy

If the hyphen is not being stored with the Zip code:
123456789 or 12345

=IIf(Len([ZIP]>5,Left([ZIP],5) & "-" & Right([ZIP],4),[ZIP])

If the hyphen is stored with the Zip code:
12345-6789 or 12345-

=IIf(Len([ZIP]>6,[ZIP],Left([ZIP],5))
 

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