I am trying to add two list boxes to an Access form, one is dependent on user input from the other.
My code assigned to 'after update' event in the Trend list (List35) which fails to update the Subtrend list (List37) when I click on Trend list's item. Any idea why?
Private Sub List35_AfterUpdate()
Dim strSQL As String
Dim selectedValue As Variant
' Get the selected value from the first combo box
selectedValue = Me.List35.Value
' Construct the SQL statement to filter the second combo box
strSQL = "SELECT L1_L2_Mapping.L2_Subtrend FROM L1_L2_Mapping WHERE L1_L2_Mapping.L1_Trend = " & selectedValue
' Set the RowSource of the second combo box (table 2) and requery it
Me.List37.RowSource = strSQL
Me.List37.Requery
End Sub
The Subtrend list box has a following query assigned in rowsource:
SELECT L1_L2_Mapping.L1_Trend, L1_L2_Mapping.L2_Subtrend
FROM L1_L2_Mapping
WHERE (((L1_L2_Mapping.L1_Trend)=[Forms]![Dashboard]![List35]));