View Single Post
  #1 (permalink)  
Old April 8th, 2005, 01:55 PM
mmcdonal mmcdonal is offline
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default Moving through a Do Loop

Okay, this should be simple but I can't find out how to do it.

I have a Do Loop. There is a counter and the loop runs until the counter reaches a certain number.

One of the things the loop does is look up some records in a database on each pass, but if there are no records, I want the loop to cycle prematurely. I can't get VBScript to allow me to do this.

This is sort of what I want to do but the syntax doesn't work:

'=====
Do Until i = 20
'open recordset
   If objRecordset.RecordCount = 0 Then
    i = i + 1
    Loop
   Else
    ...
   End If
i = i + 1
Loop
'=====

It's that Loop in the If Then End If statement that is not working. I get a Loop without Do error and the script won't run.

I am sure one of you has a very elegant solution. I am looking forward to smacking myself in the forehead for not thinking of it.

Thanks,



mmcdonal
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote