i have a two column combo box with one column for employee number and second
column for employee name. On the form both columns appear but i want to have
the employee number selected and the associated name appear in another text
box.How is this done?
Daniel - 19 May 2007 03:22 GMT
you could use the afterupdate event of the combo box to populate the text
box. Something like,
If isnull(Me.ComboboxName)=False then
Me.TextboxName = Me.ComboboxName.Column(1)
End if
An alternative would be to use dlookup to get the name based on the id.

Signature
Hope this helps,
Daniel P
> i have a two column combo box with one column for employee number and second
> column for employee name. On the form both columns appear but i want to have
> the employee number selected and the associated name appear in another text
> box.How is this done?
John W. Vinson - 19 May 2007 05:25 GMT
>i have a two column combo box with one column for employee number and second
>column for employee name. On the form both columns appear but i want to have
>the employee number selected and the associated name appear in another text
>box.How is this done?
A third selection, aside from Daniel's two, is to set the combo's Bound Column
property to the one you want stored (the ID); the column widths property can
be set to 0 for the ID if you don't want it visible.
Or, you can put a textbox on the form with a control source
=comboboxname.Column(n)
where n is the *zero based* index of the field you want to display - (1) to
show the second column.
John W. Vinson [MVP]
Christy Wyatt - 21 May 2007 14:24 GMT
The two answers already provided will display the employee name, but if you
want the value to save in the field you can do something like this:
Private Sub cboEmpID_BeforeUpdate(Cancel As Integer)
Set rs = CurrentProject.Connection.Execute("select [EmpName] from Topics
where EmpID = '" & Me.EmpID.Value & "'")
Me.[EmpName] = rs("EmpName")
Set rs = Nothing
End Sub
End Sub

Signature
Christy Wyatt
> i have a two column combo box with one column for employee number and second
> column for employee name. On the form both columns appear but i want to have
> the employee number selected and the associated name appear in another text
> box.How is this done?