View Single Post
  #1 (permalink)  
Old October 4th, 2004, 09:13 AM
hadeniyi hadeniyi is offline
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to hadeniyi
Default looping through access table.

Q: I'm trying to loop through an access table while comparing field value to one another testing if they are in sequence order. If test sequence is is not true then add on to the previouse field value and assign it to a text box. below is the code; Can anyone convey as to why I recieve this error message:Item not found in this collection. (Error 3265)

An attempt to reference a name in a collection failed.
Possible causes:


  Set rstD = CurrentDb.OpenRecordset("SELECT ACCOUNT FROM [20XXXX1]", dbOpenDynaset)
   Set rstD2 = CurrentDb.OpenRecordset("SELECT ACCOUNT FROM [20XXXX1]", dbOpenDynaset)

rstD.MoveFirst
rstD2.MoveFirst



For i = 0 To rstD.RecordCount + 1

  For j = 0 To rstD.RecordCount + 2

      If rstD.Fields(j).Value - rstD.Fields(i).Value > 1 Then
            ACCOUNT.Value = Val(rstD.Fields(i).Value) + 1
          Exit Sub
      End If
       rstD.MoveNext
      Next j
    rstD2.MoveNext
 Next i

rstD.Close
rstD2.Close
Set rstD = Nothing




Reply With Quote