I have a form where the user enters a zip code and the city and state is automatically filled in. I am using the following code:
Private Sub ZipCode_Exit(Cancel As Integer)
Me!State = DLookup("State", "tblZipCode", "ZipCode = " & "'" & Me!ZipCode & "'"
Me!City = DLookup("City", "tblZipCode", "ZipCode = " & "'" & Me!ZipCode & "'"
End Sub
The problem my users have told me about is that either the zip code is not found or they want enter to a zip code that corresponds to multiple cities. There are about 30,000 US zip codes that correspond to more than one city. What I want to do is if the zip code is not found or a zip code has more than one city, prompt the user to either add the zip code or show them a listbox with the choices of the multiple zip codes with cities and allow them to choose which one then passing the values to the main form. I know I will have to alter my zip code table because currently my zip code has the following fields:
Zip Code* (Primary Key)
City
State
I will have to change it to something like:
ID* (Primary Key)
Zip Code
City
State
I would appreciate any assistance.
Jason
Private Sub ZipCode_Exit(Cancel As Integer)
Me!State = DLookup("State", "tblZipCode", "ZipCode = " & "'" & Me!ZipCode & "'"
Me!City = DLookup("City", "tblZipCode", "ZipCode = " & "'" & Me!ZipCode & "'"
End Sub
The problem my users have told me about is that either the zip code is not found or they want enter to a zip code that corresponds to multiple cities. There are about 30,000 US zip codes that correspond to more than one city. What I want to do is if the zip code is not found or a zip code has more than one city, prompt the user to either add the zip code or show them a listbox with the choices of the multiple zip codes with cities and allow them to choose which one then passing the values to the main form. I know I will have to alter my zip code table because currently my zip code has the following fields:
Zip Code* (Primary Key)
City
State
I will have to change it to something like:
ID* (Primary Key)
Zip Code
City
State
I would appreciate any assistance.
Jason