Combo Box Lookup ???

D

Dave Elliott

I have a table called tblzipcode
It has 6 fields
CityID Autonumber Primary Key
City
Zip
State
Area Code
County

I have a form called ZipCodes which I use to lookup the matching
zip,city,state,etc...
The Combo that does the lookup correctlu shows the one that i want with the
matching city,state,zip, etc...
But the other fields on the form; Zip and State do not show the one that I
chose via the Combo
The second Textbox is supposed to show the matching zip for the city chosen
It's control source is =City1.Column(1)
The other Textbox is supposed to show the matching state for the city chosen
It's control source is =City1.Column(2)

Here is the problem:
After I choose the one that I want from the Combo Drop Down Box (City) , it
does not input the correct matching
zip and state, it does however fill in a city with the same name that I
selected with the matching
zip and state.

Example, I choose Freeport, Texas 77541
It fills in Freeport, Minnesota 56331
 
J

Jacco

Dave Elliott said:
I have a table called tblzipcode
It has 6 fields
CityID Autonumber Primary Key
City
Zip
State
Area Code
County

I have a form called ZipCodes which I use to lookup the matching
zip,city,state,etc...
The Combo that does the lookup correctlu shows the one that i want with
the matching city,state,zip, etc...
But the other fields on the form; Zip and State do not show the one that
I chose via the Combo
The second Textbox is supposed to show the matching zip for the city
chosen
It's control source is =City1.Column(1)
The other Textbox is supposed to show the matching state for the city
chosen
It's control source is =City1.Column(2)

Here is the problem:
After I choose the one that I want from the Combo Drop Down Box (City) ,
it does not input the correct matching
zip and state, it does however fill in a city with the same name that I
selected with the matching
zip and state.

Example, I choose Freeport, Texas 77541
It fills in Freeport, Minnesota 56331
What kind of info is inside the combobox?

You can use the On Change event for the combo box.

Private Sub ComboBoxName_Change()
[Zip].Value= DoCmd.RunSQL "SELECT zip FROM tblzipcode WHERE combobox = value
End Sub

Jacco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Auto Fill 0
dependent combo boxes 1
Sql insert statment from from list box to table or form 2
Form help 4
Zip Code Lookup? 1
Duplicate data on combo box 7
Combo box help! 3
Combo box problem 7

Top