Combo Box Binding

G

Gajanan

I have master table named Emp_Master with fields Emp_ID and Emp_Name. I want
to bind the combo box with name in such a way that it will display the names
of employee but I should be able to use Emp_ID in background so that I can
query different table using this value in where condition.
I have Emp_ID field in table to which I want to query later but no Emp_Name.
Please Help!
 
J

John W. Vinson

I have master table named Emp_Master with fields Emp_ID and Emp_Name. I want
to bind the combo box with name in such a way that it will display the names
of employee but I should be able to use Emp_ID in background so that I can
query different table using this value in where condition.
I have Emp_ID field in table to which I want to query later but no Emp_Name.
Please Help!

YOu can include both fields in the Combo Box's RowSource query. For instance,
the query might be

SELECT Emp_ID, Emp_Name FROM Emp_Master ORDER BY Emp_Name;

Set the combo box's properties so that the ColumnCount is 2 (to include both
fields); set the ColumnWidths property to

0;1.25"

to conceal the Emp_ID (in a zero width column), leaving the name in a 1.25
inch column (or any suitable size). Make the Bound Column property 1 and the
user will see the name, but referring to the combobox name in code or in the
control source of another control will get the ID.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top