|
4#
楼主 |
发表于 2011-3-25 22:16:06
|
只看该作者
Private Sub cmdplan_Click()
Dim onqty As Long
Dim STemp As String
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
STemp = "Select * From pack_plan"
Rs.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'删除欠包数量为零的记录
DoCmd.SetWarnings False
STemp = "delete * from solist where lackqty=0"
DoCmd.RunSQL STemp
'-----------------------------------------------------------------------------------
'对在库量按纳期先后进行分配
Rs.MoveFirst '指针指到第一条记录
Do Until Rs.EOF = True '对数据循环计算,直到最后一条记录为止
onqty = Nz(DLookup("distri", "stock", "codeno='" & Rs("codeno") & "'and yearmonth='" & Me.yearmonth & "'and area='库存区'"), 0)
If Rs("lackqty") <= onqty Then
'更新分配数
Rs("distri") = Rs("lackqty")
Rs.Update
'更新可分配数
STemp = "update stock set distri=distri-" & Rs("lackqty") & " where codeno='" & Rs("codeno") & "'and yearmonth='" & Me.yearmonth & "'and area='库存区'"
DoCmd.RunSQL STemp
End If
Rs.MoveNext '指针跳到下一条记录
Loop '继续: Do Until rs.EOF = True
End Sub
入库时对可分配库存增加更新,记录集源为按纳期排序的查询。
以上为本人对此问题的处理办法,希望对相关人员有所帮助。 |
|