老师好!
在窗口的SQLTable中用下列代码筛选后,再统计,为什么总是统计的日期时段内的所有数据而不是筛选后的表中的数据?请指点,谢谢!
Dim Filter As String
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= '" & .Value & "'"
End If
End With
With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= '" & .Value & "'"
End If
End With
DataTables("加班窗口_table1").LoadFilter = Filter
DataTables("加班窗口_table1").Load()
Dim dd1 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker3")
Dim dd2 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker4")
Dim val1 As Date = dd1.Value
Dim val2 As Date = dd2.Value
Tables("加班窗口_table1").Filter = "[病人姓名] Is not null And [接诊时间] >= '" & new Date(1900,1,1,val1.Hour,val1.Minute,val1.Second) & "' And [接诊时间] <= '" & new Date(1900,1,1,val2.Hour,val2.Minute,val2.Second) & "'"
Dim g As New CrossTableBuilder("统计表1", DataTables("加班窗口_table1"))
g.HGroups.AddDef("日期", DateGroupEnum.Year, "年度")
g.HGroups.AddDef("日期", "月份")
g.HGroups.AddDef("加班内容", "处理过程")
g.VGroups.AddDef("接诊医生", "{0}_接诊人数")
g.Totals.AddDef("病人姓名", AggregateEnum.Count, "病人姓名")
g.HorizontalTotal = True
g.VerticalTotal = True
Tables("加班窗口_table2").DataSource = g.BuildDataSource