zip code formatting

techexpressinc

Registered User.
Local time
Today, 11:09
Joined
Nov 26, 2008
Messages
185
i have zips that
12345-
and
12345-1234

The problem is the dash is on the field of the 5 digit zips. So the shortest zip is 6 characters. When putting the data on reports we do not want the dash to show on the 5 digit zips. But do want it do show on the 9 digit zips.

I am not sure how to code that. I am thinking I need a new field that is created from the original and drop the dash some how.

All ideas are welcome.
Thx
Russ
 
Re: zip code formatting - more info

i attached a picture of data.
Rus
 

Attachments

  • zipcodes-5-and-9-v9-20-10.JPG
    zipcodes-5-and-9-v9-20-10.JPG
    22.1 KB · Views: 179
Use Len and left functions

Control source in your report

=IIF(Len([ZIP])>5, [ZIP], Left([ZIP],5))

JR
 
Re: zip code formatting - not there yet

This is confusing why the - does not get carried forward.

The 5 digit zips work great.

The 9 digit zips sometimes carry the dash forward sometimes not?

See the snapshots.

Thx
Russ
 

Attachments

  • zip field definition v09-20-10.JPG
    zip field definition v09-20-10.JPG
    16.3 KB · Views: 255
  • zip test 3pm EST.JPG
    zip test 3pm EST.JPG
    41.6 KB · Views: 189
Re: zip code formatting - not there yet

Try
Code:
=IIF(Len([ZIP])<6, Mid(ZIP,1,5), Mid(ZIP,1,5) & "-" & Mid(ZIP,7,4))
 
Re: zip code formatting - DIFFERENT but still bad

Very interesting results.
It is like there are invisible characters, sometimes.

Take a look at the results.

Maybe, it have to be some conversion to all CHAR then
the length parameters.

Rus
 

Attachments

  • test 4 - v09-20-10.JPG
    test 4 - v09-20-10.JPG
    40.1 KB · Views: 162
Re: zip code formatting - DIFFERENT but still bad

Use Len to see if you get a length of 10 for each entry.
You can also try ZIP= CStr(ZIP) to see if that resolves anything. It may be possible, but unlikely, that you have a non-printing ASCII character embedded in the string.
 
Re: zip code formatting = Sovled

IIF(Len(zip)=6, Left(zip,5),IIF(Len(zip)=9,Format(Zip,"@@@@@-@@@@"),Zip))

Thx for all the help.

Russ
 

Users who are viewing this thread

Back
Top Bottom