0

how can i save a data in listview1? i have a problem to my code heres my code

Dim objNewListItem As ListItem
Set rs = New ADODB.Recordset
rs.Open "Select * from Supplier", cn, adOpenKeyset, adLockPessimistic
rs.MoveFirst

Do While Not rs.EOF
    Set objNewListItem = lvwCustomer.ListItems.Add(, , rs.Fields("scode"))
    objNewListItem.SubItems(mlng_Supp_Name) = rs.Fields("sname") & ""
    objNewListItem.SubItems(mlng_Supp_Address) = rs.Fields("saddress") & ""
    objNewListItem.SubItems(mlngSuppContactno) = rs.Fields("scontactno")
    rs.MoveNext
Loop

everytime i click my command button, the list item in a listview1 is having a duplication. .
help me thanks. .

2
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by ryan311
0

Before reloading a list view, combobox or other controls like this use .Clear

lvwCustomer.clear

empty old values and reload again

0

i have an error

Operation is not allowed when the object is closed?

0

something in the bigger picture is amiss.

clear the list view control first, then open and run your database connection and listview filler sub

Doe them in two separate functions or subs to keep things clear, simple and debuggable.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.