下图所示的数据表子表单在每个单元格中都有一个组合框。如果您在左侧的一个单元格中选择一个新值,则右侧的单元格需要重新查询并设置为空(因为右侧的组合框被左侧的组合框过滤)。如果数据表中只有一行,我的代码运行良好。但是,如果有多个,我的代码会将所有组合框重置到右侧,跨越所有行(这很糟糕)。我需要在我的代码中进行哪些更改(在下面进一步列出)才能仅重置与选择的组合框位于同一行的字段?
这是第一个组合框上的 VBA:
Private Sub cbo_LOA_Segment1_AfterUpdate()
' requery all subsequent LOA combo boxes to
' show only LOAs matching the selected Agency AND that match the earlier LOA entries
With Me
!cbo_LOA_Segment2 = Null
!cbo_LOA_Segment2.Requery
!cbo_LOA_Segment3 = Null
!cbo_LOA_Segment3.Requery
!cbo_LOA_Segment4 = Null
!cbo_LOA_Segment4.Requery
!cbo_LOA_Segment5 = Null
!cbo_LOA_Segment5.Requery
!cbo_LOA_Segment6 = Null
!cbo_LOA_Segment6.Requery
!cbo_LOA_Segment7 = Null
!cbo_LOA_Segment7.Requery
!cbo_LOA_Segment8 = Null
!cbo_LOA_Segment8.Requery
!cbo_LOA_Segment9 = Null
!cbo_LOA_Segment9.Requery
!cbo_LOA_Segment10 = Null
End With
End Sub