Proper indentation will go a long way to you being able to keep more of your hair. Whether or not you start indenting after Sub() line, what comes after can help you spot mistakes before you even try to compile. Yours adapted:
Code:
For ListOfItemsIndex = 1 to TotalNumberofItems
Do
If QTY = TOTALQTY then Exit Do
With RECORDSET
.AddNew
!BarCode = BarCode(ListOfItemsIndex)
!Brand = Brand(ListOfItemsIndex)
!Cost = Cost!(ListOfItemsIndex)
!Price = Price!(ListOfItemsIndex)
.update
QTY = QTY + 1
Loop
Next ListOfItemsIndex
Even if you didn't now know what the issue is, it should be obvious that one element of a pair is missing.
EDIT - OK maybe not if you didn't know With / End With is a pair.
Last edited by Micron; 08-25-2023 at 06:51 AM.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.