User selects an item from (Combo box1). A value is passed to an unbound Combo box 2. I am trying to populate Combo box 2 (row source) based on the value passed from DAO recordset.
Private Sub cboEmployeeName s_AfterUpdate()
intEmpID = Me!cboEmployeeN ames.Value
Call PopulateEmploye esComboBox(Me)
Function PopulateEmploye esComboBox(objF orm As Form)
Dim db As Database, rec As Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordse t("SELECT * FROM qryGeEmployeesB enefits WHERE fkBenf =" & intEmpID, dbOpenDynaset)
If rec.RecordCount = 0 Then
MsgBox "No Benefits!"
objForm.cboComb o2.Value = ""
Exit Function
Else
'Pass value to combo box 2 and populate rowsource
Do Until rec.EOF = True
intBenefitID = rec.Fields(0)
sBenefitName = rec.Fields(1)
or (neither the above or below syntax works)
objForm.cboComb o2.AddItem rec!(intBenefit ID)
objForm.cboComb o2.AddItem rec!(sBenefitNa me)
rec.MoveNext
Loop
End Function
Private Sub cboEmployeeName s_AfterUpdate()
intEmpID = Me!cboEmployeeN ames.Value
Call PopulateEmploye esComboBox(Me)
Function PopulateEmploye esComboBox(objF orm As Form)
Dim db As Database, rec As Recordset
Set db = CurrentDb()
Set rec = db.OpenRecordse t("SELECT * FROM qryGeEmployeesB enefits WHERE fkBenf =" & intEmpID, dbOpenDynaset)
If rec.RecordCount = 0 Then
MsgBox "No Benefits!"
objForm.cboComb o2.Value = ""
Exit Function
Else
'Pass value to combo box 2 and populate rowsource
Do Until rec.EOF = True
intBenefitID = rec.Fields(0)
sBenefitName = rec.Fields(1)
or (neither the above or below syntax works)
objForm.cboComb o2.AddItem rec!(intBenefit ID)
objForm.cboComb o2.AddItem rec!(sBenefitNa me)
rec.MoveNext
Loop
End Function