Re: Help error with loop!
You can't subtract 1 from 0, the last time thru your loop.
Either add one to the counter, and subtract in code, or the opposite
Re: Help error with loop!
Re: Help error with loop!
Notice that you didn't get the FIRST item?
Code:
For j = lvOrderList.ListItems.Count-1 To 0 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
End If
Next j
Re: Help error with loop!
Actually that should be count -1 to 0
Code:
Do
orderQnty = lvOrderList.ListItems(j).ListSubItems(2).Text
rsProducts.Edit
rsProducts!Units_InStock = rsProducts!Units_InStock + orderQnty
rsProducts.Update
Loop Until rsProducts.EOF
Why the loop here?
It would appear that this would be endless as you are looping until EOF but not moving the record pointer???
Looks liek you are only needing to update one record and if so no loop is needed. If you want to update more than one record or even if you only want to update a single record and update where query would be a better choice.
Re: Help error with loop!
Didn't catch that. Correct.