|
以下是调拨单的“提交”键代码(提交后将增减调入方。调出方的库存,目前只有厂部与一个门市之间相互调拨),当按“提交”键后出现提示:“BOF或EOF中有一个是真,或当前记录已被删除“,不知何因,请高手指教!
Private Sub 提交_Click()
On Error GoTo Err_提交_Click
Dim i, j, k As Integer
Dim StrTemp As String
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
Dim Rs1 As ADODB.Recordset
Set Rs1 = New ADODB.Recordset
Dim Rs2 As ADODB.Recordset
Set Rs2 = New ADODB.Recordset
StrTemp = "Select * From 调拨单"
Rs.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
StrTemp = "Select * From 八一库存"
Rs1.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
StrTemp = "Select * From 厂部库存"
Rs2.Open StrTemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
'如果“调拨单”为空,则退出
If Rs.RecordCount <= 0 Then
Exit Sub
End If
Rs.MoveFirst
For i = 0 To Rs.RecordCount - 1
CunZai = False
If Me![调入方] = "八一门市" Then
If Rs2.RecordCount < 1 Then
CunZai = False
Else
'判断记录库存中是否存在,是则更新库存信息
Rs2.MoveFirst
For j = 0 To Rs2.RecordCount - 1
If Rs2("货号") = Rs("货号") Then
If (Rs2("库存数量") - Rs("数量")) < 0 Then
MsgBox Rs("品名") & "的库存不足,请及时进货!", vbCritical, "库存不足"
Else
Rs2("库存数量") = Rs2("库存数量") - Rs("数量")
Rs2("库存金额") = Rs2("库存数量") * Rs2("库存单价")
<FONT face="Times N |
|