Dim Filter As String
With e.Form.Controls("cmbProduct")
If .Value IsNot Nothing Then
Filter = "产品名称 = '" & .Value & "'"
End If
End With
With e.Form.Controls("gongxu")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "工序名称 = '" & .Value & "'"
End If
End With
With e.Form.Controls("dingdanhao")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "生产单号 = '" & .Value & "'"
End If
End With
With e.Form.Controls("StartDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= #" & .Value & "#"
End If
End With
With e.Form.Controls("EndDate")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= #" & .Value & "#"
End If
End With
If Filter > "" Then Filter = " and " & Filter
DataTables("生产进度汇总表").StopRedraw
DataTables("生产进度汇总表").DataRows.Clear
Dim Arys As List(Of String())
Arys = DataTables("数据源表").SQLGetValues("产品名称|工序名称|生产单号", "产品名称 is not null" & Filter )
For Each Ary As String() In Arys
Dim dr As DataRow = DataTables("生产进度汇总表").AddNew()
dr("产品名称") = Ary(0)
dr("工序名称") = Ary(1)
dr("生产单号") = Ary(2)
dr("实际生产数") = DataTables("数据源表").SQLCompute("sum(数量)","产品名称 = '" & Ary(0) & "' And 工序名称='" & Ary(1) & "' And 生产单号 " & IIF(Ary(2) > ""," ='" & Ary(2) & "'" , " Is Null") )
Next
Dim dt As DataTable
Dim g As New SQLGroupTableBuilder("统计表1", "成品入进仓数")
g.Groups.AddDef("产品名称")
g.Groups.AddDef("生产单号")
g.Totals.AddDef("完工入库数量")
dt = g.Build(False)
For Each dr As DataRow In dt.DataRows
DataTables("生产进度汇总表").ReplaceFor("完工入库数量",dr("完工入库数量"),"[产品名称] = '" & dr("产品名称") & "' And 生产单号 " & IIF(dr.IsNull("生产单号")," Is Null"," ='" & dr("生产单号") & "'"))
Next
Dim g2 As New SQLGroupTableBuilder("统计表2", "订单数量表")
g2.Groups.AddDef("产品名称")
g2.Groups.AddDef("生产单号")
g2.Totals.AddExp("计划生产数","int([订单数量] * 1.02)")
dt = g2.Build(False)
For Each dr As DataRow In dt.DataRows
DataTables("生产进度汇总表").ReplaceFor("计划生产数",dr("计划生产数"),"[产品名称] = '" & dr("产品名称") & "' And 生产单号 " & IIF(dr.IsNull("生产单号")," Is Null"," ='" & dr("生产单号") & "'"))
Next
DataTables("生产进度汇总表").ResumeRedraw
把GetValues改为SQLGetValues,把Compute改为SQLCompute就可以了,这个问题解决。
[此贴子已经被作者于2020/2/23 17:25:00编辑过]