Format Zip Code

  • Thread starter Thread starter Andy
  • Start date Start date
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
 
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))
 
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))
 
Back
Top