For Each

R

Rachiano

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.
 
B

Brendan Reynolds

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
 
R

Rachiano

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top