Dim Filter As String
Dim d1 As Date
Dim d2 As Date
If e.Node.Text <> "显示所有行" Then
Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行
Dim Year As Integer =dr("年")
Select Case e.Node.Level
Case 0
Filter = "[公司名称] = '" & dr("公司名称") & "'"
Case 1
Filter = "[公司名称] = '" & dr("公司名称") & "' And [科目编号] = '" & dr("科目编号") & "'"
Case 2
d1 = New Date(Year,1,1) '取得该年的第一天
d2 = new Date(Year,12,31) '取得该年的最后一天
Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# and [公司名称] = '" & dr("公司名称") & "' And [科目编号] = '" & dr("科目编号") & "'"
End Select
End If
Tables("明细分类_table1").Filter = Filter