|
下面其他功能均有效,就是黑体大字部分功能不能实现,即将记录保存到表的功能不起作用,请高手指教!
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
Dim Rs3 As ADODB.Recordset
Set Rs3 = 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
StrTemp = "Select * From 调拨单历史"
Rs3.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("库存单价")
Rs2.Update
'把"Cunzai"变量值设为真
CunZai = True
'退出循环
Exit For
End If
|
|