H
Howard Brody
A ComboBox will display the values form a number of fields
but only stores one of them (the bound column).
First, I would change the BoundColumn of your ComboBox
from 2 to 1 (It is possible to have more than 1 employee
with the same name but the ID should still be different).
Then, I would fill in the other controls with DLookUps
(check the Help files for the details on DLookUps):
Private Sub CounseledBy_AfterUpdate()
' declare variables
Dim strID as String
Dim strEmp as String
Dim strDept as String
strID = [CounseledBy]
' look up employee name and department
strEmployee = DLookUp("[Employee]", "L_Employees", _
"[ID]='" & strID & "'")
strDept = DLookUp("[Dept]", "L_Employees", _
"[ID]='" & strID & "'")
' populate controls
[CounseledByEmployee] = strEmp
[counseledByDept] = strDept
End Sub
Hope this helps!
Howard Brody
but only stores one of them (the bound column).
First, I would change the BoundColumn of your ComboBox
from 2 to 1 (It is possible to have more than 1 employee
with the same name but the ID should still be different).
Then, I would fill in the other controls with DLookUps
(check the Help files for the details on DLookUps):
Private Sub CounseledBy_AfterUpdate()
' declare variables
Dim strID as String
Dim strEmp as String
Dim strDept as String
strID = [CounseledBy]
' look up employee name and department
strEmployee = DLookUp("[Employee]", "L_Employees", _
"[ID]='" & strID & "'")
strDept = DLookUp("[Dept]", "L_Employees", _
"[ID]='" & strID & "'")
' populate controls
[CounseledByEmployee] = strEmp
[counseledByDept] = strDept
End Sub
Hope this helps!
Howard Brody