Combo Box Record #

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that uses a combo box to retreive an employee name from a table. The key table field is the employee id #
I want the combo box record # to change to the employee number of the employee name I select or type in. (auto fill is enabled). I assume this is doable but ???
Right now if I select a name on the form when I go to the table the name ends up twice with two different employee numbers.
 
Chuck,

Sounds as if you have your combo box bound to the
Employee Name field. If you are just wanting to use this
combo box to select an employee so you can find his
record, then you need to remove the binding to any field
and just have this combo box be unbound. Then put code in
the After Update event of the combo box that will move
the user to the selected record.

Here is one way to do this (my comments are preceeded
with a single quote):

Private Sub cboYourComboBox_AfterUpdate()
'define a variable to hold the value of the combo box
'in my case it was an autonumber field so I used:
Dim lngId As Long
'in your case it may me a text field if so
Dim strEmpNumber as String
'use one or the other

'then assign the value of the combo box to the variable
strEmpNumber = me.cboYourComboBox
'move the focus to the field you are going to search on
'in your case it would be your Employee Number field
Me.EmployeeNumberFieldName.SetFocus
'move to the record using the selected value
DoCmd.FindRecord strEmpNumber

HTH

Byron
-----Original Message-----
I have a form that uses a combo box to retreive an
employee name from a table. The key table field is the
employee id #.
I want the combo box record # to change to the employee
number of the employee name I select or type in. (auto
fill is enabled). I assume this is doable but ????
Right now if I select a name on the form when I go to
the table the name ends up twice with two different
employee numbers.
 
Back
Top