大概如此:
Dim Filter As String
If e.form.Controls("TextBox1").Value IsNot Nothing Then
Filter = "姓名 = '" & e.form.Controls("TextBox1").Value & "'"
End If
If e.form.Controls("DateTimePicker1").Value IsNot Nothing Then
If filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= #" & e.form.Controls("DateTimePicker1").Value & "#"
End If
If e.form.Controls("DateTimePicker2").Value IsNot Nothing Then
If filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= #" & e.form.Controls("DateTimePicker2").Value & "#"
End If
Dim g As New GroupTableBuilder("统计表1", DataTables("基础数据"))
Dim Val As String = Forms("报表管理器").Controls("ComboBox1").Value
g.Filter = filter
g.Groups.AddDef("姓名")
If Val Is Nothing Then
MessageBox.Show("对不起,请先输入查询类型!", "提示")
ElseIf Val = "按月" Then
g.Groups.AddDef("日期",DateGroupEnum.month,"月")
ElseIf Val = "按天" Then
g.Groups.AddDef("日期",DateGroupEnum.day,"日")
ElseIf Val = "按周" Then
g.Groups.AddDef("日期",DateGroupEnum.week,"周")
ElseIf Val = "按季度" Then
g.Groups.AddDef("日期",DateGroupEnum.quarter,"季度")
ElseIf Val = "按年" Then
g.Groups.AddDef("日期",DateGroupEnum.year,"年")
End If
g.Totals.AddDef("呼叫次数")
g.Totals.AddDef("总单量")
g.VerticalTotal = True
g.Build()
MainTable = Tables("统计表1")
[此贴子已经被作者于2012-8-21 17:41:17编辑过]