Zipcodes Autofill in Contacts Suppliers Customers City State

Sharuc

New member
Local time
Today, 05:45
Joined
Jan 31, 2012
Messages
2
I have a Zipcode database which I imported in the Northwind database Access template. I have been looking for a solution where in forms such as "Suppliers" "Customers" "Users" the contact information forms to fill the City and State when user inputs the zip code in "Zip Code/Postal Zone" box. Being a newbie at the Access your valuable help is much appreciated. Thank you.
Sharuc
 
Thanks Paul,
I have seen this link earlier when I was trying to get a solution..
Please bare with me, I tried the code below,

Private Sub zip_AfterUpdate()
Dim varState, varCity As Variant
varState = DLookup("State", "zipcodes", "zip =[Zip] ")
varCity = DLookup("City", "zipcodes", "zip =[Zip] ")
If (Not IsNull(varState)) Then Me![State] = varState
If (Not IsNull(varCity)) Then Me![City] = varCity
End Sub

I opened th e Contact Form in design mode and in code window pasted the above code, with Zipcodes being the table to lookup, saved and opened the form and entered a zip code but nothing filled the City and State! Can you guide me with any simple database to work on. Thank you.
 
Sorry, I had a server go down that week and lost track of some threads. Did you get this sorted out? I wouldn't go that way because of the overhead of repeated DLookups. If you want to stay with it, your syntax is off:

http://www.mvps.org/access/general/gen0018.htm
 

Users who are viewing this thread

Back
Top Bottom