开发者

Issue with Recordset

I'm having an issue getting my recordset to work properly in the following code, and am unsure if its a personal runtime error of part of the inherent shabbiness of VBA. the code is as follows

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

Now, the issue is with reading the database. When method readVendor is called on form load, it functions perfectly. when it is called on lst item click, i get Error 3021: Either BOF, EOF or record deleted. Any guidance very much appreciated. Thanks in advance


rstVendor.Find "VendorNo = " & Me.lstVendors

was something found? and/or is rstVendor still open?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜