Formatting Zip Codes

G

Guest

Hi! I'm trying to format a zip code so that it appears in the report as
12345-6789 if there are 9 digits in the underlying table of as 12345 if the
table only contains the 5 digit zip code. Right now I'm using the following
code which is omitting the dash:[City] & ", " & [State] & " " & Format([Zip
Code],"00000")
Can you help? Thanks.
 
G

Guest

Try this --
IIF(Len([Zip Code])>5, Format([Zip Code],"00000-0000"), Format([Zip Code],
"00000"))
 
F

fredg

Hi! I'm trying to format a zip code so that it appears in the report as
12345-6789 if there are 9 digits in the underlying table of as 12345 if the
table only contains the 5 digit zip code. Right now I'm using the following
code which is omitting the dash:[City] & ", " & [State] & " " & Format([Zip
Code],"00000")
Can you help? Thanks.

The Zips might be 12345-6789 or 12345- or 12345
so...

=[City] & ", " & [State] & IIf(Len([Zip])>6,[Zip],Left([Zip],5))
 
G

Guest

Thanks...works perfectly.

KARL DEWEY said:
Try this --
IIF(Len([Zip Code])>5, Format([Zip Code],"00000-0000"), Format([Zip Code],
"00000"))

--
KARL DEWEY
Build a little - Test a little


JRSNHECI said:
Hi! I'm trying to format a zip code so that it appears in the report as
12345-6789 if there are 9 digits in the underlying table of as 12345 if the
table only contains the 5 digit zip code. Right now I'm using the following
code which is omitting the dash:[City] & ", " & [State] & " " & Format([Zip
Code],"00000")
Can you help? Thanks.
 

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

Top