错误91:运行此代码时抛出对象变量或With block变量未设置:
Private Sub Cmdsave_Click()
Dim db As database
For i = 0 To LISTQTY.ListCount - 1 Step 1
db.Execute "Updatable tblstock set boxQty = boxQty + " & LISTQTY.Column(1, i) & " where PID=" & Me.LISTQTY.Column(0, i) & ""
'CurrentDb.Updatable
Next
End Sub
答案 0 :(得分:0)
未设置数据库变量。
Private Sub Cmdsave_Click()
Dim db As database
Set db = CurrentDb
For i = 0 To LISTQTY.ListCount - 1 Step 1
db.Execute "Updatable tblstock set boxQty = boxQty + " & LISTQTY.Column(1, i) & " where PID=" & Me.LISTQTY.Column(0, i) & ""
Next
End Sub
或者只使用CurrentDb
CurrentDb..Execute "Updatable tblstock set boxQty = boxQty + " & LISTQTY.Column(1, i) & " where PID=" & Me.LISTQTY.Column(0, i) & ""