Mark has attended:
Access Intermediate course
Access Advanced course
Access VBA course
Using both fields/columns selected in combo box
Hi,
I am studying the code from the vba course. I have a combo box cmbEmployee and we made it load with the Employee ID field (hidden by zero column width) and the Employee name for the user to select. The ID is taken (by way of default) to store in the intEmployee variable.
The bit I am interested in is the label for the sales analysis output. Currently I have sales of the product selected and "by employee 4" for example. I want to obtain a second variable from the combo selection so that I can show the name and not the ID here.
I have inserted Dim strEmployee As String to be in addition to Dim intEmployee as Integer but would love to know how I obtain the employee name for the string whilst still also having the integer variable.
Thanking you in anticipation --
Regards, Mark
RE: Using both fields/columns selected in combo box
I have luckily come across the same problem posted by someone else on another forum. To access the other columns in the combo box one can use the .column(col no) reference. The first column is 0. Hence for my two column combo I got two values to play with using the following.
intEmployee = Me.cmbEmployee.Value
strEmployeeName = Me.cmbEmployee.Column(1)
Regards, Mark