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
<strong> con.Execute "DELETE from Supplier where Supplier_Name='" & ListView1.ListItems(x).SubItems(1) & "'"
ListView1.ListItems.Remove x
con.CommitTrans</strong>
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
cguan_77
Nearly a Posting Virtuoso
1,317 posts since Apr 2007
Reputation Points: 19
Solved Threads: 115
I see you set con = nothing, but where do you dim con? where do you set con?
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215