Fill in City, ST information from ZIP alone.

Build your list of AccuZIP6 commands by requesting commands and sharing commands with other users

Moderators: Chrissy, Steve, Terry, Donna, Dave, Eric, MartyH, Kristen, Geoff, Vince

Post Reply
User avatar
Dave
Site Admin
Posts: 620
Joined: Wed Sep 20, 2006 3:20 pm

Fill in City, ST information from ZIP alone.

Post by Dave » Fri Feb 09, 2007 3:38 pm

If you have a need to populate the City and St fields when only the ZIP is available then use the following command.

Code: Select all

USE IN IIF(USED('_USZIPS'),SELECT('_USZIPS'),0)
REPLACE ZIP WITH ALLT(SUBSTR(ADDRESS,RAT(" ",ALLT(ADDRESS)))),;
	ADDRESS WITH LEFT(ADDRESS,RAT(" ",ALLT(ADDRESS)));
	FOR EMPTY(ZIP) AND ISDIGIT(RIGHT(ALLT(ADDRESS),1))
REPLACE ADDRESS WITH ALLT(ADDRESS)+" "+ZIP,;
	ZIP WITH "" FOR ISALPHA(ALLT(ZIP))
PUBLIC COMALIAS
COMALIAS=ALIAS()
USE (ADDBS(XDEFFLDR)+"DMM\_USZIPS.DBF") IN 0 ORDER USZIP
REPLACE CITY WITH _USZIPS.PREFCITY,;
	ST WITH _USZIPS.ST FOR SEEK(LEFT(ZIP,5),'_USZIPS')
USE IN IIF(USED('_USZIPS'),SELECT('_USZIPS'),0)
:shock:

Post Reply