Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining City, State, from a ZIP Code Table

Status
Not open for further replies.

mshefferVT

Technical User
Jul 9, 2002
5
US
Hey All,

I have a 4 column table with ZIP, City, Country, State. What I am looking to do is be able to input just the ZIP into a form and extract the other information and print it to the screen.

I would appreciate any help that you all could give me!

Thanks,
Matt
 
Matt, try this:
I have a zipcode table (ARCityZip) with 2 columns:
Zip, City
When the user types in the Zipcode (XXXXX-XXXX), then
moves off the Zip field, the City field is populated.
It should not be too hard to adapt to your needs.
I strip out the Zip+4 part of the zipcode:

Code:
Private Sub ZIP_CODE_AfterUpdate()

IZipCode = Trim(Left(Me![ZIP_CODE], 5))

Me![CITY] = DLookup("[City]", "ARCityZip", "[Zip]=" & "'" & IZipCode & "'")

Me.Refresh
End Sub

Chalmers
cdavis@uaex.edu
 
Oh, in case you do not know how:
To insert the code, open the form in Design view.
Right-click the Zip field.
Left-click Properties.
Click the Event tab.
Click in the [bAfter Update[/b] field.
Click the 3 dots (...).
Click on Code Builder.
Click OK.
Type in the lines above between Private Sub and End Sub.
Chalmers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top