My Code commenting sucked, My bad. So heres the update! This funtion is meant to be used when passing values from another control to a listview control with a database. I needed a way to keep duplicate entries away in the recieving Listview. The funtion is called after the row insertion on a double click event or Drag and drop.It works because the index is set dynamicaly by the database values.If used out of context it WILL delete everything, which in fact, does suck. I used LCase incase you want to pass a nonnumerical value(which i did and then did not), but you can remove it, no harm, no foul. Hope this helps. Feedback is very welcome. Please Feedback, Please.
Assumes
Example of use: RS is a record set in case you needed to know.
With rs ' Recordset
On Error Resume Next
Do While Not .EOF 'list products of a specific category on ListView starts loop
Set rs = ListView2.ListItems.Add(, , !Productid, 1, 1)
rs.SubItems(1) = !ProductName
rs.SubItems(2) = !Unit
rs.SubItems(3) = Format(!PRICE, "Currency")
rs.SubItems(4) = Format(!Extcost, "Currency")
rs.SubItems(5) = Format(!Retail, "Currency")
rs.SubItems(6) = Format(!Add)
cTotal = cTotal + CCur(rs.SubItems(3)) * (rs.SubItems(6)) ' here the math part , really simple CCur sets it as Currency
rs.SubItems(7) = Format(cTotal, "Currency")
.MoveNext ' Restarts loop till EOF
Loop
.Close
End With
Call RemoveDupes(ListView2)
ListView2.Refresh
End Sub
Side Effects
DO NOT USE OUT OF CONTEXT> IF YOU NEED A REGULAR DEDUPE FUNCTION EMAIL ME> YOU ARE MY FRIEND> I WILL HELP YOU>MABEY