-
Loop error
Code:
For j = lvOrderList.ListItems.Count To 1 Step -1
If rsProducts!Product_ID = lvOrderList.ListItems(j).Text Then
Do
orderQnty = lvOrderList.ListItems(j).ListSubItems(2).Text
rsProducts.Edit
rsProducts!Units_InStock = rsProducts!Units_InStock + orderQnty
rsProducts.Update
Loop Until rsProducts.EOF
Next j
next without for error
-
Re: Loop error
When you post code please put it inside code tags so it is displayed in a more readable way - either using the Code/VBCode buttons in the post editor screen (or at the top of the Quick Reply box), or by putting them in manually, like this: [code] code here [/code] . I have added them to your post.
The error is actually telling you the wrong thing, but that is due to a surprising level of complexity for VB to deal with.
The problem is that a control structure (For-Next / Do-Loop / If - End If / ...) has been opened but not closed (or closed without being opened, but that does not apply here).
This is one of the many cases where indenting your code helps, as you should easily be able to spot which one is causing the issue.
-
Re: Loop error
Added the end if but still does not loop through to get
rsProducts!Product_ID = lvOrderList.ListItems(j).Text
-
Re: Loop error
It isn't clear what you mean by that, but I can see issues with your code... a big one being the Do-Loop not having a way out (you don't change record inside it, so how can .EOF change?)