Runtime Error: 3021

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darrel
    New Member
    • Nov 2006
    • 72

    #1

    Runtime Error: 3021

    Hi there, can someone tell me what is wrong with my code am getting a run time error 3021:

    Here my code:

    Code:
    If rs.State = adStateOpen Then rs.Close
          rs.Open "Select * from [SUBJECTS] where ID like 'ABA0102%'", cnn, adOpenKeyset, adLockOptimistic
             
      While rs.EOF <> True
        For x = 0 To 15
            
            txtSubjects(x).Text = rs.Fields("SUBJECT").Value
            rs.MoveNext
            
        Next x
     
      Wend
    Am getting the eror on this line
    Code:
      txtSubjects(x).Text = rs.Fields("SUBJECT").Value
    Hope somebody can help me out here.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    I'd guess you've moved past the end of the recordset. The test for EOF on the While loop is only checked when you reach the end of the While loop, to decide whether to go 'round again.

    So you are saying something like...

    "Am I at the end yet? No? Good, then grab the next 16 records."

    Presumably, there were less than 16 records available.

    Comment

    Working...