CipherIS
asked on
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
Any idea how to resolve?
RecordsetError.JPG
Try just this:
x=0
Do Until rs.EOF
Me.varAircraftType.AddItem = rs(x).Value
x=x+1
Loop
x=0
Do Until rs.EOF
Me.varAircraftType.AddItem
x=x+1
Loop
ASKER
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mx