|
Do Until N = True
If Y = False Then
DoCmd.SetWarnings (False)
DoCmd.RunSQL "DELETE 漆包线车间假设明细.* FROM 漆包线车间假设明细;"
DoCmd.RunSQL "INSERT INTO 漆包线车间假设明细 SELECT 漆包线车间明细.* FROM 漆包线车间明细;"
DoCmd.RunSQL "DELETE 漆包线仓库假设明细.* FROM 漆包线仓库假设明细;"
DoCmd.RunSQL "INSERT INTO 漆包线仓库假设明细 SELECT 漆包线明细仓库.* FROM 漆包线明细仓库;"
Y = True
Else
stemp = "Select * From 漆包线消耗明细"
rs.Open "Select * From 漆包线消耗明细", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do While Not rs.EOF
a = rs.Fields("根数")
c = DCount("条形码", "漆包线车间假设明细", "货品ID='" & rs("铜线货品ID") & "'")
If a - c > 0 Then
For i = 1 To a - c Step 1
If DCount("条形码", "漆包线仓库假设明细", "货品ID='" & rs("铜线货品ID") & "'") > 0 Then
b = DLookup("条形码", "漆包线应追加明细", "货品ID='" & rs("铜线货品ID") & "'")
DoCmd.RunSQL "INSERT INTO 漆包线车间假设明细 ( 货品ID, 条形码, 数量 ) SELECT 漆包线应追加明细.货品ID, 漆包线应追加明细.条形码, 漆包线应追加明细.数量 FROM 漆包线应追加明细 GROUP BY 漆包线应追加明细.货品ID, 漆包线应追加明细.条形码, 漆包线应追加明细.数量 HAVING (((漆包线应追加明细.货品ID)='" & rs("铜线货品ID") & "'));"
DoCmd.RunSQL "DELETE 漆包线仓库假设明细.* FROM 漆包线仓库假设明细 where 条形码='" & b & "';"
Y = True
Else
MsgBox "此有绕阻定子计划车间及仓库" & rs("铜线货品ID") & "漆包线桶数不足,请修改此计划", vbDefaultButton1
Set rs = Nothing
Set rs1 = Nothing
Exit Sub
End If
Next i
Else
STemp1 = "select * from 漆包线车间假设明细 where 货品ID='" & rs("铜线货品ID") & "'"
rs1.Open STemp1, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do While Not rs1.EOF
If rs("每根数量") > rs1("数量") Then
If DCount("条形码", "漆包线仓库明细", "货品ID=" & rs("货品ID") & "") > 0 Then
b = DLookup("条形码", "漆包线应追加明细", "货品ID='" & rs("铜线货品ID") & "'")
DoCmd.RunSQL "INSERT INTO 漆包线车间假设明细 ( 货品ID, 条形码, 数量 ) SELECT 漆包线应追加明细.货品ID, 漆包线应追加明细.条形码, Min(漆包线应追加明细.数量) AS 数量 FROM 漆包线应追加明细 GROUP BY 漆包线应追加明细.货品ID, 漆包线应追加明细.条形码 HAVING (((漆包线应追加明细.货品ID)='" & rs("货品ID") & "'));"
DoCmd.RunSQL "DELETE 漆包线仓库假设明细.* FROM 漆包线仓库假设明细 where 条形码=" & b & ";"
Y = True
Else
MsgBox "此有绕阻定子计划车间及仓库'" & rs("货品ID") & "'漆包线重量不足,请修改此计划", vbDefaultButton1
Set rs = Nothing
Set rs1 = Nothing
Exit Sub
End If
Else
rs1.MoveNext
End If
Loop
End If
Set rs1 = Nothing
rs.MoveNext
Loop
Set rs = Nothing
DoCmd.SetWarnings (True)
End If
N = True
Loop
总是执行到 For i = 1 To a - c Step 1 。。。Next i 就结束了,不再判断重量,请帮忙看看为什么。谢谢了。 |
|