Delete selected (treeview) rows from data table in Visual basic 6.0

How to delete selected items from a data table (Access) in Visual basic 6.0 ? Users can select the item using a list view control.

Get the count of selected items first

For k = 1 To ListView_Slaes.ListItems.count
If ListView_Slaes.ListItems(k).Checked = True Then
selCount = selCount + 1
End If

Get selected items deleted

Dim t
If selCount > 0 Then

For C = 1 To Me.ListView_Slaes.ListItems.count

Set itmX = Me.ListView_Slaes.ListItems(C)
If itmX.Checked = True Then

takesql = “select * from stockmovement where itemname = ‘” & Trim(itmX.SubItems(1)) & “‘ ”
t = “And OpStock = ” & Val(Trim(itmX.SubItems(2)))
takesql = takesql + t
Set rs = MedicalShop.OpenRecordset(takesql)
If rs.RecordCount > 0 Then
End If
End If
Next C
MsgBox “Please select an ordered item(s) to remove”, vbInformation, “Selection error”
End If

Published by


A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.