1.先产生一个临时表,来取年度值.Dim g As New GroupTableBuilder("统计表1", DataTables("表A"))
g.Groups.AddDef("日期", DateGroupEnum.Year, "年")
g.Totals.AddDef("编号", AggregateEnum.Count, "数量")
g.Build()
'MainTable = Tables("统计表1")
2.取得自定义项目
Dim nian As WinForm.ComboBox = e.Form.Controls("ComboBox1")
nian.ComboList = DataTables("统计表1").GetComboListString("年") & "|全部"
3.当表查询时,可正常取值
Dim nian As WinForm.ComboBox = e.Form.Controls("ComboBox2")
If nian.Value = "全部" Then
Tables("表A").Filter = ""
Else
Dim dt As Date = new Date(nian.value, 1, 1) '定义选择年度的第1天
Tables("表A").filter = "日期 >= '" & dt & "' And 日期 < '" & dt.addyears(1) & "' "
End If
4.当需要取值产生新统计表时,只能取值1次
Dim nian As WinForm.ComboBox = e.Form.Controls("ComboBox1")
If nian.Value = "全部" Then
Dim g2 As New GroupTableBuilder("统计表2", DataTables("表A"))
g2.Groups.AddDef("日期", DateGroupEnum.Year, "年")
g2.Totals.AddDef("编号", AggregateEnum.Count, "数量")
g2.Build()
'MainTable = Tables("统计表2")
Tables("统计_Table1").DataSource = g2.BuildDataSource
Tables("统计_Table1").font = New Font("宋体", 12)
Else
Dim dt As Date = new Date(nian.value, 1, 1) '定义选择年度的第1天
Dim g2 As New GroupTableBuilder("统计表2", DataTables("表A"))
g2.Filter = "日期 >= '" & dt & "' And 日期 < '" & dt.addyears(1) & "' "
g2.Groups.AddDef("日期", DateGroupEnum.Year, "年")
g2.Totals.AddDef("编号", AggregateEnum.Count, "数量")
g2.Build()
'MainTable = Tables("统计表2")
Tables("统计_Table1").DataSource = g2.BuildDataSource
Tables("统计_Table1").font = New Font("宋体", 12)
End If
[此贴子已经被作者于2016/4/22 14:16:46编辑过]