PDA

View Full Version : Solved: record type for loop



Movian
11-03-2009, 09:58 AM
Hey,
i like to try and do my coding the 'Right' way where possible. I strongly feel that when looping through records in a record set i should be using a for loop.

for each record in myrs
do somthing
next

However i am unable to find a record type dim rec as record or anything similar.... am i going about this the wrong way ? i know i can achieve this with a while not myrs.eof however that means i need to add in a superfluous extra line myrs.movenext While a for loop would automatically increment itself. I'm just trying to use a for loop in a situation it was designed for but i seem do be stuck with a while loop.... any thoughts ?

CreganTur
11-03-2009, 12:30 PM
Either of these is considered correct:

Do Until rs.EOF
Do While Not rs.EOF

Doing a For Each loop with the recordset.record object doesn't make much sense, especially when you consider that recordsets have built in methods for determining where you are in the recordset, as well as BOF/EOF. Don't overthink it ;)

Also, you will need to invoke the rs.MoveNext method, or some other move method.