我有一个问题让我的记录集在下面的代码中正常工作,并且我不确定它是否是VBA内在破坏的部分个人运行时错误。代码如下
Option Compare Database
Option Explicit
Dim dbInquiry As New ADODB.Connection
Dim rstVendor As New ADODB.Recordset
Private Sub Form_Load()
Set dbInquiry = CurrentProject.Connection
rstVendor.Open "Select * from Vendors Order By VendorName", dbInquiry, adOpenKeyset, _
adLockOptimistic, adCmdText
Me.lstVendors = rstVendor!VendorNo
Me.lstVendors.Requery
Call readVendor
End Sub
Private Sub readVendor()
Me.lblVendorNumber.Caption = rstVendor!VendorNo
Me.lblVendorName.Caption = rstVendor!VendorName
Me.lblVendorAddress.Caption = rstVendor!Address1
Me.lblVendorCity.Caption = rstVendor!City & ", " & rstVendor!Prov
Me.lblVendorPostal.Caption = rstVendor!PostCode
End Sub
Private Sub lstVendors_Click()
rstVendor.MoveFirst
rstVendor.Find "VendorNo = " & Me.lstVendors
Call readVendor
End Sub
现在,问题在于阅读数据库。当在表单加载时调用方法readVendor时,它完美地运行。当它在lst项目点击时调用,我得到错误3021:BOF,EOF或记录被删除。任何指导非常感谢。提前致谢
答案 0 :(得分:0)
rstVendor.Find“VendorNo =”& Me.lstVendors
发现了什么?和/或rstVendor仍然开放?</ p>