Combo box problem
I am developing a windows application, my database is in MS-Access, i have made one form which have 3 combobox, 1st for productkey, 2nd for employee name and 3rd for serial no. what i want is that when i fill the employee name then automatically the 3rd one i.e serial no. should be filled with that employees serial no. Please help me how to do it.

Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 17, 2009, 7:11 PM EST
Then forget the database connction part in my code.
Focus on the displaymeber, valuemember properties of the combobox2 and 3.
In combobox2 when you set those properties as I have set, and using the selected index changed event of combo box 2 you can get the expected outcome .
If you still have any problem pls ask.
If you find this answer useful please do not forget to mark it as accepted.
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 17, 2009, 6:16 PM EST
What is the language?
C# or VB? and do you need the code to connecting to DB as well?
Vandana Sardana48 reputationPosted Nov 17, 2009, 6:59 PM EST
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 17, 2009, 7:02 PM EST
I assumed you use c#.
1. First load your combo boxes with the data in database. Here, replace connection string, table names and column names in my code with the correct names.
private void Form1_Load(object sender, EventArgs e) { //First create the connection string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=....."; OleDbConnection objConnection = new OleDbConnection(strConnection); try { objConnection.Open(); //Fill combo1 DataSet ds = new DataSet(); OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT productkey FROM table_name", objConnection); adapter.Fill(ds); DataTable dt = ds.Tables[0]; comboBox1.DataSource = dt; comboBox1.DisplayMember = "productkey"; //Fill combo2 and combo3 DataSet ds2 = new DataSet(); OleDbDataAdapter adapter2 = new OleDbDataAdapter("SELECT employee_name, serial_no FROM employee_table_name", objConnection); adapter2.Fill(ds2); DataTable dt2 = ds2.Tables[0]; comboBox2.DataSource = dt2; comboBox2.DisplayMember = "employee_name"; comboBox2.ValueMember = "serial_no"; comboBox3.DataSource = dt2; comboBox3.DisplayMember = "serial_no"; objConnection.Close(); } catch (Exception e) { } }2. Then use selected index changed event of combo 2 to display the serial number in combo 3 of the selected employee in combo 2.
If you have any problem please ask.
If you find this useful, please do not forget to amrk this as accepted..