p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: VBScript Programmer's Reference, 1st, 2nd, and 3rd editions (http://p2p.wrox.com/forumdisplay.php?f=51)
-   -   looping through access table. (http://p2p.wrox.com/showthread.php?t=19357)

hadeniyi October 4th, 2004 09:13 AM

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)


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
      Next j
 Next i

Set rstD = Nothing

kari April 18th, 2006 01:27 AM

Hi hadenyiyi,

This code above is not needed since the recordset will automatically in the first location.

This code is used to count how many rows of record you have inside rstd.

This code is used to referencing (j-1)th column at certain row.

I guess your code get error since you accessing the column that may not available.

But I don't get what is your code going to do??

All times are GMT -4. The time now is 09:22 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.