Solved

MS Access VBA Recordset Error

Posted on 2010-08-28
4
426 Views
Last Modified: 2012-08-13
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
Comment
Question by:CipherIS
  • 3
4 Comments
 
LVL 75
ID: 33550590
Can you post the code instead of an image.

mx
0
 
LVL 75
ID: 33550606
Try just this:

x=0
Do Until rs.EOF
    Me.varAircraftType.AddItem = rs(x).Value
    x=x+1  
Loop
0
 
LVL 1

Author Comment

by:CipherIS
ID: 33550743
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
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 33550762
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question