Zip Code Format

  • Thread starter Thread starter DJ
  • Start date Start date
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!
 
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.
 
Back
Top