• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

MS Access VBA Recordset Error

I wrote this code below.  The recordset contains data (2 records).  When walking through the recordset rs(0).value contains data but when it gets to rs(1).value it errors out.

Any idea how to resolve?
RecordsetError.JPG
0
CipherIS
Asked:
CipherIS
  • 3
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Can you post the code instead of an image.

mx
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Try just this:

x=0
Do Until rs.EOF
    Me.varAircraftType.AddItem = rs(x).Value
    x=x+1  
Loop
0
 
CipherISAuthor Commented:
That didn't work either
Dim x As Integer
Dim db As dao.Database
Dim rs As dao.Recordset
Dim sSQL As String
    
sSQL = "SELECT [Aircraft Type] FROM tblAircraft ORDER BY [Aircraft Type]"
    
Me.varAircrafttype.AddItem ("All")
            
Set db = CurrentDb
Set rs = db.OpenRecordset(sSQL)

x = 0
If Not (rs.EOF) Then
   Do Until rs.EOF
      Me.varAircrafttype.AddItem (rs(x).Value)
      x = x + 1
   Loop
End If

Open in new window

0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Is this what you are trying to do ?

Do
    Me.varAircraftType.AddItem = rs![Aircraft Type]
    rs.MoveNext
Loop  Until rs.EOF
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now