Dim Fl As String = ""
Dim qts As String
Dim dt As DataTable=DataTables(e.Form.TableName)
If dt.SourceType = 1 Then 'Access数据源
qts="#"
ElseIf dt.SourceType = 2 Then 'SQL Server数据源
qts="'"
End If
If e.node.Name <> "显示所有行" Then '要用Name属性,不能用Text属性
Dim d1 As Date
Dim d2 As Date
Dim Year As Integer = e.Node.DataRow("年")
Dim Month As Integer = e.Node.DataRow("月")
Dim xmid As String = e.Node.DataRow("牌照号")
Select Case e.Node.Level
Case 0
d1 = New Date(Year,1,1) '取得该年的第一天
d2 = new Date(Year,12,31) '取得该年的最后一天
Fl = "统计月 >= " & qts & d1 & qts & " And 统计月 <= " & qts & d2 & qts
Case 1
d1 = New Date(Year, Month, 1) '取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) '取得该月的最后一天
Fl = "统计月 >= " & qts & d1 & qts & " And 统计月 <= " & qts & d2 & qts
Case 2
d1 = New Date(Year, Month, 1) '取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) '取得该月的最后一天
Fl = "统计月 >= " & qts & d1 & qts & " And 统计月 <= " & qts & d2 & qts & " And 牌照号 = '" & xmid & "'"
End Select
End If
With DataTables(e.Form.TableName)
.LoadFilter = fl '设置加载条件
.LoadOver="牌照号" '分页依据,不指定有可能出错
.LoadPage = 0 '加载第一页
.LoadTop = 30 '每页5行
.Load()
e.Form.Controls("TextBox2").Value = 1 & "/" & .TotalPages
End With