PDA

View Full Version : ignore recordset in loop


reubenb
07-19-2008, 08:40 PM
hi

is there anyway to ignore the current record in a loop and move to the next one?

that is, you are going through a loop and you have an if-then statement that says like, if x-field is "this" then ignore this record, go to the next one etc.

i would do it with the query of course, but if it depends on other factors etc. (and if i want to make it complicated as well) i want to know if its possible to do this?

shyam
07-20-2008, 11:09 AM
you haven't given a lot to go on...so, i'm gonna guess u want rs.moveNext()

M@rco
07-22-2008, 01:50 AM
Just to add to shyam's answer, I'm guessing you mean something like:


While Not RS.EOF
If (RS("SomeField")=MagicValue) Then
'do something...
'do something else...
'do yet another thing...
'we're now done with this record, move on!
RS.MoveNext
Else
'failed test so just move to the next record
RS.MoveNext
End If
Wend


Clearly the test in the IF statement could be anything, including more than one test, if true then do further processing, if false then skip to next record.

Spudhead
07-22-2008, 03:25 PM
why not just:

While Not RS.EOF
If (RS("SomeField")=MagicValue) Then
'do something...
End If
RS.MoveNext
Wend

M@rco
07-22-2008, 03:41 PM
Aha, you got me! Yes, that's far more elegant! :thumbsup:

(You can tell I haven't coded for a while... lol)