If Forms("材料统计").Opened Then
Dim f As New CrossTableBuilder("材料统计汇总", DataTables("表A"))
'f.HGroups.AddDef("供应商")
f.HGroups.AddDef("材料")
'f.HGroups.AddDef("型号规格")
f.VGroups.AddDef("月", "{0}")
f.Totals.AddDef("单价",AggregateEnum.Average,"单价")
' f.HorizontalTotal = True
f.Filter = "日期 Is Not Null"
f.Build()
Dim exp As String
Dim dt As DataTable = DataTables("材料统计汇总")
For Each dc As DataCol In dt.DataCols
If dc.Name Like "单价*" Then
exp += " + [" & dc.Name & "]"
End If
Next
exp = "(" & exp.Substring(3) & ") / " & dt.DataCols.Count-1
dt.DataCols.Add("合計平均", Gettype(Double), exp)
Tables("材料统计_材料统计汇总表").DataSource = dt
End If