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

Re-Query Combo Box

Status
Not open for further replies.

FortuneCookie

Technical User
Mar 8, 2005
3
0
0
GB
Hi

I have 3 combo boxes that query an MS Access DB. The code for these are in the Form_Load function, so they are populated when I start the form.
My issue is, that I need to use the value from the first combo box in the where clause of the third but of course the code has already run.

Is there a way of re-running the code for a combo box so that I can re-query with the variable that I get?

Thanks
 
How's it going?

I think what you want to do is add a selectedindexchanged event on your combo box.

so you may have something like this (not in front of an ide, so bear with syntactical errors):

Code:
ComboBox cmb1 = new ComboBox;
ComboBox cmb2 = new ComboBox;
ComboBox cmb3 = new ComboBox;

private Page_Load(...)
{
   InitBoxes();
   
   //Add Event for cmb1
   //Add Event for cmb2
   //Add Event for cmb3
}

private void InitBoxes ()
{
   //Add values to boxes...
}

private cmb1_SelectedIndexChanged(..., ...)
{
   //Do stuff
   switch (cmb1.Text)
   {
      case "cmb1TextHere":
         break;
      //and so on
   }
}
private cmb2_SelectedIndexChanged(..., ...)
{
   //Do stuff
}
private cmb3_SelectedIndexChanged(..., ...)
{
   //Do stuff
}

Sorry for the bad code, but I'm a little out of it this morning, but the concept is what you want.

Good luck!
-Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top