Discussion:
Format Zip Code
(too old to reply)
Andy
2004-06-30 20:34:36 UTC
Permalink
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
fredg
2004-06-30 20:43:07 UTC
Permalink
Post by Andy
Hi;
Need help formating Zip Codes.
Format([txtZip],"00000-0000")
And
Format([txtZip],"#####-####")
Worked great when the Zip contained 9 digits: 12345-6789
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))
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Andy
2004-07-01 12:54:45 UTC
Permalink
Fred;

Thank You.

How simple when somebody shows you how to do it.

Thank You again.

Andy
Post by fredg
Post by Andy
Hi;
Need help formating Zip Codes.
Format([txtZip],"00000-0000")
And
Format([txtZip],"#####-####")
Worked great when the Zip contained 9 digits: 12345-6789
Returns 12345-0000 or 12345-####
Anyone over come this?
Andy
123456789 or 12345
=IIf(Len([ZIP]>5,Left([ZIP],5) & "-" & Right([ZIP],4),[ZIP])
12345-6789 or 12345-
=IIf(Len([ZIP]>6,[ZIP],Left([ZIP],5))
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Loading...