Populate ComboBox2 from table according to selected value in ComboBox1 (1 Viewer)

Waheed2008

Registered User.
Local time
Today, 10:57
Joined
Jul 17, 2008
Messages
57
Hello everybudy
I have got a problem and I want help from some buddy.

I have two tables Table1 & Table2. Table1 has two fields ID and Department. Table2 has 3 fields ID, Employee & Department.

In a form, I have 2 Combo Boxes cmbDept and cmbEmp. I populate cmbDept from Table1 with departments. Now I want that when I select Department-1 from cmbDept, all the employees of Department-1, from Table2, are populated in cmbEmp. Similerly, When I select Department-3 in cmbDept, employees of Department-3 are populated in cmbEmp. Employee list in Combo Box should be dependent on Department selected. The employees of selected department should be displayed in cmbEmp.

How can I do that?? I shall realy appriciate for response.
Thanks
 

Waheed2008

Registered User.
Local time
Today, 10:57
Joined
Jul 17, 2008
Messages
57
I am using this code for populating second combobox in actual scenario. Previously I was using example and there it works fine. But now in actual scenario, My combobox shows the query, not result.
Here is code
Code:
cmbCostCodes.RowSource = "Select CostCodes.Codes " & _
        "FROM CostCodes " & _
        "WHERE CostCodes.Project = '" & cmbProject.Value & "' " & _
        "ORDER BY CostCodes.Codes;"
    cmbCostCodes.Requery
Here is result inside Combobox
Select CostCodes.Codes FROM CostCodes WHERE CostCodes.Project = 'OBM' ORDER BY CostCodes.Codes
Why is it so?
Please help me.
Thanks
 

CyberLynx

Stuck On My Opinions
Local time
Yesterday, 23:57
Joined
Jan 31, 2008
Messages
585
Set the Row Source Type property for the cmbCostCodes Combo Box to Table/Query instead of Value List.

That should take care of it.

.
 

Waheed2008

Registered User.
Local time
Today, 10:57
Joined
Jul 17, 2008
Messages
57
Great......... :)

Thanks a lot. I works according to my requirements.

Thanks again for your correction.
 

Users who are viewing this thread

Top Bottom