主要看下红字部分 用产品名称就OK 如果改成产品自动编号或者产品识别码就报错 搞不懂啊
Dim bd1 As New GroupTableBuilder("统计表1",DataTables("采购入库单明细"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("产品名称") '根据型号分组
bd1.Groups.AddDef("产品自动编号")
bd1.Groups.AddDef("产品识别码")
bd1.Groups.AddDef("规格")
bd1.Totals.AddDef("采购数量","入库数量") '对数量进行统计
''bd1.Totals.AddDef("金额","进货_金额") '对金额进行统计
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("出库明细表"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("产品名称") '根据型号分组
bd1.Groups.AddDef("产品自动编号")
bd1.Groups.AddDef("产品识别码")
bd1.Groups.AddDef("规格")
bd2.Totals.AddDef("本次出库数量","出库数量") '对数量进行统计
''bd2.Totals.AddDef("金额","销售_金额") '对金额进行统计
dt2 = bd2.BuildDataSource()
Dim bd3 As New GroupTableBuilder("统计表3",DataTables("期初库存明细"))
Dim dt3 As fxDataSource
bd3.Groups.AddDef("产品名称") '根据型号分组
bd1.Groups.AddDef("产品自动编号")
bd1.Groups.AddDef("产品识别码")
bd1.Groups.AddDef("规格")
''bd3.Totals.AddDef("数量","期初数量") '对数量进行统计
bd3.Totals.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)")
'' .Add("库存_金额",Gettype(Double), "[库存_数量] /[进货_数量] * [进货_金额]")
End With