|
编制程序如下, 运行结果都显示正常, 可查询"入库记录"和"仓库信息"两个数据库, 并没有更新数据, 求教问题在哪里, 非常感谢!
Private Sub 商品入库_Click()
Dim sql As String
Dim rst As ADODB.Recordset
Dim number As Integer
sql = "Select * from 商品 where 商品编号 = '" & Me.商品编号 & "'"
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open sql
If Not (rst.EOF) Then
'添加入库记录
sql = "select * from 入库记录"
'rst.Close
Set rst = Nothing
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockBatchOptimistic
rst.Open sql
With rst
.AddNew
!编号 = Me![编号]
!仓库编号 = Me![仓库编号]
!入库日期 = Me![入库日期]
!经手人 = Me![经手人]
!商品编号 = Me![商品编号]
!数量 = Me![数量]
!采购价格 = Me![采购价格]
!供应商编号 = Me![供应商编号]
!备注 = Me![备注]
End With
rst.Close
Set rst = Nothing
'添加或者修改库存信息
sql = "select * from 仓库信息 where 仓库编号 = " & Me![仓库编号] & " And 商品编号 = '" & Me![商品编号] & "'"
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
rst.Open sql
If Not (rst.EOF) Then
number = rst!当前库存数量
number = number + Me![数量]
rst!当前库存数量 = number
rst.Close
Set rst = Nothing
sql = "当前库存数量为: " & number
MsgBox sql
Exit Sub
Else
With rst
.AddNew
!仓库编号 = Me![仓库编号]
!商品编号 = Me![商品编号]
!当前库存数量 = Me![数量]
End With
Exit Sub
Me.Visible = False
End If
Else
rst.Close
Set rst = Nothing
MsgBox "系统中没有该商品的信息, 请先添加商品详细信息"
Exit Sub
Me.Visible = False
End If
End Sub
|
|