Re: Zip Code Lookup

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Is that not working? It appears that it should work.
Are you getting any errors?

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County

Bill wrote:
I'm trying to do a zip code look up where the user enters a zip code then the city and state is populated base on a table. My table is called ZIP_CODES and the table which will be holding all data is "Address". When the user enters the zip code into the form I want the city and state to autofill. Here's what I have:

Private Sub Zip_Code_AfterUpdate()
Dim rsCurr As DAO.Recordset
Dim strSql As String
strSql = "SELECT City, State " & _
"FROM tblZIP_CODES " & _
"WHERE Left(Zip_Code, 5) = '" & Left(txtZip_Code.Value, 5) & "'"
Set rsCurr = CurrentDb().OpenRecordset(strSql)
If rsCurr.EOF = False Then
State = rsCurr!State
txtCity = rsCurr!City
End If
End Sub

Thanks for the help.

Bill
.



Relevant Pages

  • Re: synchronize combo boxes
    ... should be for cbozip, i have changed so many times. ... Private Sub City_AfterUpdate ... " ORDER BY City" ... Zip is equal to the value of cboCity... ...
    (microsoft.public.access.gettingstarted)
  • Re: No results on a multiple parameter search
    ... For example, one column is "City". ... If I were to search for Austin, ... Private Sub cmdSearch_Click ... Dim strSql As String ...
    (microsoft.public.access.forms)
  • No results on a multiple parameter search
    ... For example, one column is "City". ... If I were to search for Austin, ... Private Sub cmdSearch_Click ... Dim strSql As String ...
    (microsoft.public.access.forms)
  • Paradox then paste into excel
    ... Private Sub Worksheet_SelectionChange(ByVal Target As ... The above works by moving the cursor over say City it then ... just need it to to as I paste into Excel workSheet. ...
    (microsoft.public.excel.programming)