Zip Code Format

D

DJ

Please advise:

I am trying to format the zip code field in my report.
There currently are no hypens in the stored zip codes.

I am entering the following:

Format([Zip Code], "@@@@@-@@@@")

This works fine, but how do I get a correct format to do
this if the zip code is ######### (nine letters), but do
not add the hyphen if the zip code is ##### (five
letters).

Thanks for your help!
 
F

fredg

Please advise:

I am trying to format the zip code field in my report.
There currently are no hypens in the stored zip codes.

I am entering the following:

Format([Zip Code], "@@@@@-@@@@")

This works fine, but how do I get a correct format to do
this if the zip code is ######### (nine letters), but do
not add the hyphen if the zip code is ##### (five
letters).

Thanks for your help!

Don't use the Format at all.
I assume you wish to use this in an address.
In an unbound text control:
=[City] & ", " & [State] & IIf(Len([ZIP Code]) <6,[ZIP Code],Left([ZIP
Code],5) & "-" & Right([ZIP Code],4))

The above should correctly format the Zip code, even if sometime in
the future you include the hyphen with the data.
 

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