By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,655 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,655 IT Pros & Developers. It's quick & easy.

Skip to Next (in a for each next loop) if condition is met

P: n/a
Hi, I cannot find the right way to write this code. I keep getting the
error : Next without For

Here's my code.

For Each Choix In RapInd_Code.ItemsSelected
S6 = LBo_RapInd_Code.ItemData(Choix)
S7 = DLookup...
S8 = DLookup...

If (S7 < 8) Or (S8 < 0.5) Then
---MY PROBLEM IS HERE---
Next Choix (HERE I WANT IT TO directly go to the next step)
Else
For i = 1 To S6
...call a procedure in SQL
Next i
End If
Next Choix
Thank you all

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Patrik wrote:
Hi, I cannot find the right way to write this code. I keep getting the
error : Next without For

Here's my code.

For Each Choix In RapInd_Code.ItemsSelected
S6 = LBo_RapInd_Code.ItemData(Choix)
S7 = DLookup...
S8 = DLookup...

If (S7 < 8) Or (S8 < 0.5) Then
---MY PROBLEM IS HERE---
Next Choix (HERE I WANT IT TO directly go to the next step)
Else
For i = 1 To S6
...call a procedure in SQL
Next i
End If
Next Choix
Thank you all


Just take out the middle "next", since the rest of the loop is in the
"else" condition the code will skip it down to the proper "next"

--
[OO=00=OO]
Nov 13 '05 #2

P: n/a
On 13 Jul 2005 13:19:48 -0700, Patrik wrote:
Hi, I cannot find the right way to write this code. I keep getting the
error : Next without For

Here's my code.

For Each Choix In RapInd_Code.ItemsSelected
S6 = LBo_RapInd_Code.ItemData(Choix)
S7 = DLookup...
S8 = DLookup...

If (S7 < 8) Or (S8 < 0.5) Then
---MY PROBLEM IS HERE---
Next Choix (HERE I WANT IT TO directly go to the next step)
Else
For i = 1 To S6
...call a procedure in SQL
Next i
End If
Next Choix

Thank you all


For Each Choix In RapInd_Code.ItemsSelected
S6 = LBo_RapInd_Code.ItemData(Choix)
S7 = DLookup...
S8 = DLookup...

If (S7 < 8) Or (S8 < 0.5) Then

' *** Nothing is needed here
Else
For i = 1 To S6
...call a procedure in SQL
Next i
End If
Next Choix
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.