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
next without for error
the unit in stock should be updated with the data in listview(orderQnty). the productID from listview should first match with ProductID in database.
should then move on to next listview and update...
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
Last edited by dglienna; February 24th, 2011 at 12:19 AM.
Reason: Actually that should be count -1 to 0
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.
Last edited by DataMiser; February 23rd, 2011 at 01:33 PM.
Bookmarks