Foxproboy 发表于:2016-02-02 22:54:12
请教各位大侠:
我现在文本框更新过程中通过ADODB 定义了2个数据集rst和rst1并打开数据表,想在另一个按钮的点击过程里将定位到记录追加到另一个表中。
但是系统执行到点击过程的“rst1.addnew”时系统出现错误:“Run-time error 424: 'object required' ”
啥原因?
1. 文本框更新过程
Private Sub t2_AfterUpdate()
Dim rst,rst1 As ADODB.Recordset '
Dim strsql, strsql1 As String '
strsql = "select * from Spareparts"
strsql1 = "select * from SInbound"
Set rst = New ADODB.Recordset
Set rst1 = New ADODB.Recordset
rst.Open strsql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rst1.Open strsql1, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Do While Not rst.EOF
If Me.t2.Value = rst!StockNo.Value Then
For i = 3 To 18
Me("t" & i).Enabled = True
Next
Me.t3.Value = rst!Name.Value
Me.t4.Value = rst!CriticalCls.Value
'Me.T5.Value = rst!Birthday.Value
Me.t6.Value = rst!specification.Value
Me.t7.Value = rst!PartNo.Value
Me.t8.Value = rst!ArtNo.Value
Me.t9.Value = rst!Brand.Value
Me.t10.Value = rst!manufacturer.Value
'Me.t11.Value = rst!Shoesize.Value
Me.t12.Value = rst!Subprice3.Value
'Me.t13.Value = rst!Weight.Value
Me.t14.Value = rst!safetystock.Value
Me.t15.Value = rst!Onstock.Value
Me.t16.Value = rst!shelvesNo.Value
Me.t17.Value = rst!Purpose.Value
Me.t18.Value = rst!Remark.Value
Exit Do
Else
rst.MoveNext
End If
Loop
If rst.EOF Then
For i = 3 To 18
Me("t" & i).Value = Null
Me("t" & i).Enabled = True
Next
MsgBox "this's a new material!"
End If
End Sub
2. 新增记录点击过程
Private Sub Command48_Click()
rst1.AddNew
rst1!IBdate.Value = Me.T1.Value
rst1!StockNo.Value = Me.t2.Value
rst1!Name.Value = Me.t3.Value
rst1!CriticalCls.Value = Me.t4.Value
rst1!pono.Value = Me.T5.Value
rst1!specification.Value = Me.t6.Value
rst1!PartNo.Value = Me.t7.Value
rst1!ArtNo.Value = Me.t8.Value
rst1!Brand.Value = Me.t9.Value
rst1!manufacturer.Value = Me.t10.Value
rst1!DeliveryTime.Value = Me.t11.Value
rst1!Price.Value = Me.t12.Value
rst1!Inbound.Value = Me.t13.Value
rst1!safetystock.Value = Me.t14.Value
rst1!shelvesNo.Value = Me.t16.Value
rst1!Purpose.Value = Me.t17.Value
rst1!IRemark.Value = Me.t18.Value
rst1.Update
rst1.Close
Set rst1 = Nothing
MsgBox Me.t2.Value & "records is done!"
For i = 3 To 18
Me("t" & i).Value = Null
Me("t" & i).Enabled = False
Next
End Sub
删除冗余的字段即可
总记录:1篇 页次:1/1 9 1 :