"Do While..." loop won't compile (1 Viewer)

Talia Young

New member
Local time
Today, 18:54
Joined
Apr 19, 2002
Messages
6
I'm having trouble compiling a "Do While..." loop. I've tried to simplify the code as much as possible.

Do While (True)
'do a lot of stuff
If (strCurrentRecord = strLastRecord) Then Exit Do
Loop

When I compile the code, I get a "Loop without Do" error at the Loop.

At first, I was using "While...Wend," but I changed that. Then I thought maybe I should be using "Exit While" instead of Loop, but I get a syntax error with that.

So I'm not sure what I'm doing wrong. Any help would be greatly appreciated.
 

Fizzio

Chief Torturer
Local time
Today, 18:54
Joined
Feb 21, 2002
Messages
1,885
You could try

Do While strCurrentRecord <> strLastRecord
etc
Loop

or

Do Until strCurrentRecord = strLastRecord
etc
Loop
 

Emohawk

What a wicked mullet...
Local time
Today, 18:54
Joined
Mar 14, 2002
Messages
79
I'm positive the syntax is
Code:
While True
'Your Code here

If (strCurrentRecord = strLastRecord) Then 
   Goto ExitLoop
End if

Wend

ExitLoop:
'The code will jump to here when If condition met
or
Code:
While strCurrentRecord <> strLastRecord
'Your Code here

Wend
Try putting up more of your code if this doesn't help.
 

Talia Young

New member
Local time
Today, 18:54
Joined
Apr 19, 2002
Messages
6
Hooray! I found the problem by commenting out all of the code in between and adding it back in line by line. Thanks for your help and sorry for the bother.
 

Users who are viewing this thread

Top Bottom