I'm a relative newbie to this, so any assistance will be appreciated.
I am attempting to write a VBA module to populate a combo box with a list of valid data based on input from a previous field.
My problem is that the module returns only the value for the first record in the lookup table, which not only is incorrect, but also is not a list.
The Event Procedure for this is as follows:
Private Sub Dept_ID_AfterUpdate()
On Error Resume Next
Dim CostCenter As String
' Evaluate filter before it's passed to DLookup function.
CostCenter = "Cost_Cntr = " & Forms![entry form]![datasum subform]![dept id]"
' Look up valid WO's for this department
Me!WO_number = DLookup("Ref_no", "project codes", CostCenter)
Exit_Dept_ID_AfterUpdate:
Exit Sub
Err_Dept_ID_AfterUpdate:
MsgBox "Error Number " & Err.Number & ":" & Err.Description
Resume Exit_Dept_ID_AfterUpdate
End Sub
I am attempting to write a VBA module to populate a combo box with a list of valid data based on input from a previous field.
My problem is that the module returns only the value for the first record in the lookup table, which not only is incorrect, but also is not a list.
The Event Procedure for this is as follows:
Private Sub Dept_ID_AfterUpdate()
On Error Resume Next
Dim CostCenter As String
' Evaluate filter before it's passed to DLookup function.
CostCenter = "Cost_Cntr = " & Forms![entry form]![datasum subform]![dept id]"
' Look up valid WO's for this department
Me!WO_number = DLookup("Ref_no", "project codes", CostCenter)
Exit_Dept_ID_AfterUpdate:
Exit Sub
Err_Dept_ID_AfterUpdate:
MsgBox "Error Number " & Err.Number & ":" & Err.Description
Resume Exit_Dept_ID_AfterUpdate
End Sub