Tables(e.Form.Name & "_Table7").DataSource = dt5 '将统计结果绑定到Table
With DataTables(e.Form.Name & "_Table7").DataCols '用表达式列计算上月结存和本月结存
.Add("上月结存_数量",Gettype(Double), "IsNull([上月总入库_数量],0) - ISNULL([上月总出库_数量],0)")
.Add("上月结存_金额",Gettype(Double), "IsNull([上月总入库_金额],0) - ISNULL([上月总出库_金额],0)")
.Add("本月结存_数量",Gettype(Double), "IsNull([本月总入库_数量],0) - ISNULL([本月总出库_数量],0)")
.Add("本月结存_金额",Gettype(Double), "IsNull([本月总入库_金额],0) - ISNULL([本月总出库_金额],0)")
End With
Dim t As Table = Tables(e.Form.Name & "_Table7")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "上月总入库_数量,上月总入库_金额,上月总出库_数量,上月总出库_金额,本月进_数量,本月进_金额,本月出_数量,本月出_金额,本月总入库_数量,本月总入库_金额,本月总出库_数量,本月总出库_金额,上月结存_数量"
g.Caption = "总计"
t.SubtotalGroups.Add(g)
t.autosizecols()
t.Cols("上月总入库_数量").Visible = False
t.Cols("上月总入库_金额").Visible = False
t.Cols("上月总出库_数量").Visible = False
t.Cols("上月总出库_金额").Visible = False
t.Cols("本月总入库_数量").Visible = False
t.Cols("本月总入库_金额").Visible = False
t.Cols("本月总出库_数量").Visible = False
t.Cols("本月总出库_金额").Visible = False
t.Subtotal()