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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto fill information 1

Status
Not open for further replies.

nkll

IS-IT--Management
Jan 21, 2004
9
US
I have a table "City"
within that table I have "County" , "Zip"

What is the best way to design a form so the user selects from a drop down box the "city" , then the "county" and "Zip" are automatically prefilled for them??


Thanks...

 
You would have to have a table that has all the counties and zip codes for the cities listed in it.

Then on the form in the After Update event of the drop down box you would lookup the county and zip.

Example:

Private Sub MyCombo_AfterUpdate()

County = DLookup("[County]","tblCountyZips","[City]='" & MyCombo & "'")
Zip = DLookup("[Zip]","tblCountyZips","[City]='" & MyCombo & "'")

End Sub

HTH
Mike

[noevil]
 
What are you going to do for cities that have more than one zipcode? I know Albuquerque really isn't a "large" city, but it's the largest in the state and we have at least 7 zipcodes that are all for city Albuquerque, county Bernalillo.


Leslie
 
thanks for the design tip...I had not thought about that...for what I am doing though, a small geographic area...it will not be an issue.
 
Zipcodes have always been a pain in the butt. For duplicate zipcodes one could check for duplicates first...
Code:
If DCount("[Zip]","tblCountyZips","[City]='" & MyCombo & "'")>1 Then
and then pop-up a form that contains the small list of duplicates that the user can choose from.
Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top