For Each

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I want to run a "for each" statement within a "for each" statement.
My recordsources are adodb recordsets. I want to execute code for each record
in the recordsets.
How do I refer to each record in my recordset?
Thanks.
 
I don't believe you can loop through the records with a "For Each", because,
to the best of my knowledge, the individual records in the recordset are not
members of a collection. You can easily do it with a Do Until ... Loop,
though ...

Do Until rst.EOF
'Fields *are* members of a collection ...
For Each fld In rst.Fields
'do something with each field
Next fld
'move to next record
rst.MoveNext
Loop
 
Many Thanks Brendan.

Brendan Reynolds said:
I don't believe you can loop through the records with a "For Each", because,
to the best of my knowledge, the individual records in the recordset are not
members of a collection. You can easily do it with a Do Until ... Loop,
though ...

Do Until rst.EOF
'Fields *are* members of a collection ...
For Each fld In rst.Fields
'do something with each field
Next fld
'move to next record
rst.MoveNext
Loop
 
Back
Top