Can anyone tell me how should i delete listview checked data using
delete button. right now i got error object variable or with block
variable not set.
Private Sub Command3_Click()
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim x As Integer
con.BeginTrans
For x = ListView1.ListItems.Count To 1 Step -1
If ListView1.ListItems(x).Checked = True Then
con.Execute "DELETE from Supplier where Supplier_Name='" & ListView1.ListItems(x).SubItems(1) & "'"
ListView1.ListItems.Remove x
con.CommitTrans
End If
Next
con.Close
Set con = Nothing
End Sub
i just re-arrange your code i put the con.begintrans before the for loop.. check if it will help
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
Offline 1,317 posts
since Apr 2007