Connecting Tech Pros Worldwide Forums | Help | Site Map

Leading Zeroes in ZIP Code

DanCole42
Guest
 
Posts: n/a
#1: Jul 25 '08
Newbie question, here.

I have a database that frequently imports ZIP code data that
frequently needs cleaning:

12365
6487
64684-3543
3213-6546


I.e. missing leading zeroes, five digit vs nine digit ZIPs, etc.

How would I format the "Update To" command to: 1) restore leading
zeroes to four and eight digit zips and 2) standardize all ZIPs to
five digits??

Thanks!

Tom van Stiphout
Guest
 
Posts: n/a
#2: Jul 25 '08

re: Leading Zeroes in ZIP Code


On Fri, 25 Jul 2008 06:41:57 -0700 (PDT), DanCole42
<dancole42@gmail.comwrote:

First off you need a text field.
Then make the first pass and strip off anything starting with "-". You
could do that with a combination of Left$ and InStr.
Then make a second pass and add leading zeros. You could do that with
Format or with Len.

Give it a try.

-Tom.
Microsoft Access MVP


Quote:
>Newbie question, here.
>
>I have a database that frequently imports ZIP code data that
>frequently needs cleaning:
>
>12365
>6487
>64684-3543
>3213-6546
>
>
>I.e. missing leading zeroes, five digit vs nine digit ZIPs, etc.
>
>How would I format the "Update To" command to: 1) restore leading
>zeroes to four and eight digit zips and 2) standardize all ZIPs to
>five digits??
>
>Thanks!
paii, Ron
Guest
 
Posts: n/a
#3: Jul 25 '08

re: Leading Zeroes in ZIP Code


iif(instr(1,[ZIP],"-")=0,format([ZIP],"00000"),format(left([ZIP],instr(1,[ZI
P],"-")-1),"00000"))

"DanCole42" <dancole42@gmail.comwrote in message
news:5dffda2c-c504-4043-91c8-fe6dbae0b9ae@k36g2000pri.googlegroups.com...
Quote:
Newbie question, here.
>
I have a database that frequently imports ZIP code data that
frequently needs cleaning:
>
12365
6487
64684-3543
3213-6546
>
>
I.e. missing leading zeroes, five digit vs nine digit ZIPs, etc.
>
How would I format the "Update To" command to: 1) restore leading
zeroes to four and eight digit zips and 2) standardize all ZIPs to
five digits??
>
Thanks!
>

Closed Thread


Similar Microsoft Access / VBA bytes