Solved

MS Access VBA Recordset Error

Posted on 2010-08-28
4
422 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 - Access MVP) 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now