你看清楚有点甜说的原因了吗?
正确的代码应该是:
Dim bd1 As New GroupTableBuilder("统计表1",DataTables("成品入库明细表"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("地板型号") '根据型号分组
bd1.Groups.AddDef("批次")
bd1.Totals.AddDef("计算件数","入库件数") '对数量进行统计
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("成品出库明细表"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("地板型号") '根据型号分组
bd2.Groups.AddDef("批次")
bd2.Totals.AddDef("计算件数","出库件数") '对数量进行统计
dt2 = bd2.BuildDataSource()
Dim bd3 As New GroupTableBuilder("统计表3",DataTables("退货明细表"))
Dim dt3 As fxDataSource
bd3.Groups.AddDef("地板型号") '根据型号分组
bd2.Groups.AddDef("批次")
bd3.Totals.AddDef("退货件数","退货件数") '对数量进行统计
dt3 = bd3.BuildDataSource()
dt1.Combine("地板型号",dt2,"地板型号") '将销售统计数据组合到进货统计数据
dt1.Combine("地板型号",dt3,"地板型号") '将退货统计数据组合到进货统计数据
Tables("批次库存_Table1").DataSource = dt1 '将统计结果绑定到Table
With DataTables("批次库存_Table1").DataCols '用表达式列计算库存数据
.Add("库存件数",Gettype(Integer), "IsNull([入库件数],0) + ISNULL([退货件数],0) - ISNULL([出库件数],0)")
End With
Tables("批次库存_Table1").Filter =" 地板型号 ='" & Tables("成品出库明细表").Current("地板型号") & "'"
Tables("批次库存_Table1").Sort = "批次"