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

A combo looking up another combo?

Status
Not open for further replies.

jiejie

Technical User
Oct 8, 2003
6
US
I have two combo boxes on a form, one is sourced from a table listing of all states, and the other one is sourced from a query that pulls out the zip codes of the state chosen on the first combo box. I then set a command to rerun that query every time a different state is chosen in the first combo box (at the OnChange event), supposing that the second combo box would only pick up those zip codes that reside within the state chosen. This only works the very first time when the state combo box is populated, but the zip code combo box never update again when I pick a different state. Any ideas?
 
Do you have any code behind the controls? If you do it would be of great benefit to you for us to be able to see what your code looks like so that we may be able to further assist you.

If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmm
 
"Peeping Tom",

There's not much to peep here - no, I don't have codes behind the control. I did it the "dummy" way - I clicked on the combo box icon on the tool bar and then just followed the wizard by telling it to link to the query, which supposedly runs off the state chosen on the first combo box. I tested the query separately and that seems to run OK, except the combo box that's supposed to pick up the results does not update. Oh, I totally forgot, I do have codes behind the first combo:

Private Sub Combo2_Click()
If Combo1.Value > 0 Then
DoCmd.Requery
End If
 
Okay, I usually do this with list boxes but the premise is still the same it seems. Your first combo box has States in it fine and dandy. Now, your second combo box should have the zipcodes in it and the States field. Uncheck the check box for the States field so that it will not be visible when you run the query. Then use the "Build..." command from the right click menu to go to your form and to the control for the States only. Now that is going to tell the Zip combo box to basically show all records for what ever State you select. Then you want to code the following code into the After Update event of the State control:

Me!ZipControlName = Null
Me!ZipControlName.Requery

So that code should tell the State control that after you select a new state that it needs to set the Zip control to null and then do a requery of the control.



If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top