''''
Dim exp As String = "1=1"
Dim sq1 As String="selec 套数,入库, 出库,(isnull(套数,0)-isnull(出库,0)) as 结存, a.* from (SELEC * FROM 订单) a left join("
Dim sq2 As String="Selec 订单号, sum(入库) As 入库, sum(出库) As 出库 from (Selec 订单号, 数量 As 入库, 0 As 出库 from {成品入库单明细} where " & exp & ""
'Dim sq3 As String="union all Selec 产品编码,0, 盈亏数量 from {盘点单明细} where " & exp & ""
'Dim sq4 As String="union all Selec 产品编码,0, 数量 from {调拨单明细} where " & ck1 & ""
'Dim sq5 As String="union all Selec 产品编码,数量, 0 from {调拨单明细} where " & ck2 & ""
Dim sq6 As String="union all Selec 订单号,0,数量 from {成品出库单明细} where " & exp & ") As d group by 订单号) As b on a.订单号 = b.订单号"
Tables(e.form.Name & "_Table1").fill(sq1 &sq2 &sq6,"wjhansdata",True)
Tables(e.form.Name & "_Table1").SetColVisibleWidth("订单号|98|日期|100|周别|180|订单PO号|180|成品料号|200|工令|180|套数|90|入库|90|出库|90|结存|128|")
Tables(e.form.Name & "_Table1").DefaultRowHeight = 23
Tables(e.form.Name & "_Table1").DataTable.AllowResizeRow=False
If Tables(e.form.Name & "_Table1").rows.count=0
Tables(e.form.Name & "_Table1").GrandTotal = False
Else
Tables(e.form.Name & "_Table1").Cols("出库").GrandTotal = True
Tables(e.form.Name & "_Table1").Cols("入库").GrandTotal = True
Tables(e.form.Name & "_Table1").Cols("结存").GrandTotal = True
Tables(e.form.Name & "_Table1").Cols("套数").GrandTotal = True
Tables(e.form.Name & "_Table1").GrandTotal = True '显示合计模式
End If