-
Table = Assets
-
Key Department User
-
1 Accounting John
-
2 Accounting Sue
-
3 Sales Peter
-
4 Personel Nancy
-
5 Accounting Frank
-
I see your table as above. In this case, selecting User from a combo box would find a single Department, and no selection (and no combo box) would be necessary. The result would be a single Department. The code might be:
cboUser.ControlSource = "SELECT Department, User FROM Assets ORDER BY User;" In design view for your form, the Bound Column for cboUser would be 1 and the Row Source Type would be Table/Query. Then txtDisplayDepartment = cboUser would assign the Department to a text box, no operator action needed.
To work the other way, and select the Department, then cboDepartment.ControlSource = "SELECT Department FROM Assets ORDER BY Department;" Once selected (Change event), then cboUser.ControlSource = "SELECT User FROM Assets WHERE Department=""" & cboDepartment & """ ORDER BY User;" Both of these combo boxes have the bound column = 1.
You will have to set Column Count and Column Widths for these combo boxes in design view. In the first example, Column Widths will be 0";2" or whatever you need, but the 0" hides the first column.
Better database design would have 2 tables, Departments and Users. The FROM clause would change in the above examples.
OldBirdman