I want to have Access enter the values of city name and state abbreviation when I enter the zip code in a field. I have the database for the zip codes, but I need an example database of whatever linking or codes I have to perform to have these actions automated for me. The zip is entered and then the city and state fields are automatically looked up and the fields populated with the correct information. I can't find anything that is easy or clear online (probably because folks make their money off of their databases :-)). Anyone have their access database automated already? Or does anyone have a link to an existing database example that I could look at for a lead?
2007-01-26
09:14:01
·
6 answers
·
asked by
CruelNails
3
in
Computers & Internet
➔ Programming & Design
I did find this code, but I am so new to access it means nothing to me :-) Would this work, provided I understood what exactly was happening?
************* Code Start **************
' This code was originally written by Erika Yoxall.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Erika Yoxall
'
Sub Zip_OnExit(Cancel As Integer)
Dim varState, varCity As Variant
varState = DLookup("State", "tblZipCode", "ZipCode =[Zip] ")
varCity = DLookup("City", "tblZipCode", "ZipCode =[Zip] ")
If (Not IsNull(varState)) Then Me![State] = varState
If (Not IsNull(varCity)) Then Me![City] = varCity
End Sub
'************* Code End **************
2007-01-26
11:08:09 ·
update #1