Hi Experts. I dont know wats wrong with the loop below. But when i call this function its supposed to insert the records in a listbox into a db access db table. but it saves the first record twice. Wat could i be doing wrong?
e.g
Product Code
124318N Mkate
124318N Mkate
141652G Rice
Code:Sub AddToList() With dbData.Recordset For i = 1 To lvprod.ListItems.Count .AddNew .Fields(0) = lvprod.ListItems(i).Text 'prod code .Fields(1) = lvprod.ListItems(i).SubItems(2) .Fields(2) = txtPrice.Text 'price .Fields(3) = lvprod.ListItems(i).SubItems(1) 'qty .Fields(4) = 0 .Fields(5) = lvprod.ListItems(i).SubItems(4) .Fields(6) = Month(Now) .Fields(7) = Year(Now) .Update Next i dbData.Refresh End With End Sub




Reply With Quote