-- 窗口显示临时表
我想生成的临时表在窗口显示,下面代码提示Tables("欠货统计_欠货统计表")不存在
\'欠货统计
\'生成统计表
Dim dtb As New DataTableBuilder("欠货统计")
dtb.AddDef("客户", Gettype(String), 32)
dtb.AddDef("产品", Gettype(String), 32)
dtb.AddDef("颜色", Gettype(String), 32)
dtb.AddDef("订单数量", Gettype(Integer))
dtb.AddDef("发货数量", Gettype(Integer))
dtb.AddDef("欠货数量", Gettype(Integer))
dtb.Build()
\'填充数据
Dim f As New Filler
f.SourceTable = DataTables("销售订单明细")
f.SourceCols = "客户,产品,颜色"
f.DataTable = DataTables("欠货统计")
f.DataCols = "客户,产品,颜色"
f.Fill()
\'统计
For Each dr As DataRow In DataTables("欠货统计").DataRows
dr("订单数量") = DataTables("销售订单明细").Compute("Sum(订单数量)","[客户] = \'" & dr("客户") & "\' and [产品] = \'" & dr("产品") & "\' and [颜色] = \'" & dr("颜色") & "\'")
dr("发货数量") = DataTables("产品明细").Compute("Sum(出仓数量)","[客户] = \'" & dr("客户") & "\' and [产品] = \'" & dr("产品") & "\' and [颜色] = \'" & dr("颜色") & "\'")
dr("欠货数量") = dr("订单数量") - dr("发货数量")
Next
\'MainTable= Tables("统计")
Tables("欠货统计_欠货统计表").DataSource = DataTables("欠货统计")
\'设置月份的列宽
\'For Each c As Col In Tables("欠货统计_欠货统计表").Cols
\'If c.DataCol.IsNumeric Then
\'c.Width = 50
\'End If
\'Next
Tables("欠货统计_欠货统计表").AutoSizeCols() \'设置自动列宽
\'删除数值为空的记录
\'DataTables("欠货统计").DeleteFor("[合计] = 0" )
forms("欠货统计").open()
[此贴子已经被作者于2018/2/28 13:26:09编辑过]