I have a form that has both an Access Listview and Treeview & have successfully coded it so that I can drag & drop a single item from the listview onto a treeview node. However, I am struggling with dropping multiple items from the listview onto the treeview node. In dissecting the VBA in the Listview1_Click event I found that it is successful in iterating through the selected items, but only grabs the ID from the last item selected. Here is the VBA:
For i = 1 To ListView1.listItems.Count
If ListView1.listItems(i).Selected Then
'MsgBox (i) 'use this to see the iteration(s)
If FiltStr = "" Then
FiltStr = "ID = '" & ListView1.SelectedItem.ListSubItems(7).Text & "'"
Else
FiltStr = FiltStr & " OR ID = '" & ListView1.SelectedItem.ListSubItems(7).Text & "'"
End If
MsgBox ("Filtstr = " & FiltStr)
End If
Next
So if only 1 item is selected, the FiltStr successfully completes as " ID = '123' ". If 3 items are selected, the Filtstr completes as " ID = '456' OR ID = '456' OR ID = '456' " which is the ID of the last item selected. It is successfully building the Filtstr but is only grabbing the last ID each time through. (I used the MsgBox to see what ID it was collecting each time through the iteration.)
I am hopeful someone can help me as I find that documentation on Listview in Access somewhat scarce. Thanks in advance for any help!
-Rod
For i = 1 To ListView1.listItems.Count
If ListView1.listItems(i).Selected Then
'MsgBox (i) 'use this to see the iteration(s)
If FiltStr = "" Then
FiltStr = "ID = '" & ListView1.SelectedItem.ListSubItems(7).Text & "'"
Else
FiltStr = FiltStr & " OR ID = '" & ListView1.SelectedItem.ListSubItems(7).Text & "'"
End If
MsgBox ("Filtstr = " & FiltStr)
End If
Next
So if only 1 item is selected, the FiltStr successfully completes as " ID = '123' ". If 3 items are selected, the Filtstr completes as " ID = '456' OR ID = '456' OR ID = '456' " which is the ID of the last item selected. It is successfully building the Filtstr but is only grabbing the last ID each time through. (I used the MsgBox to see what ID it was collecting each time through the iteration.)
I am hopeful someone can help me as I find that documentation on Listview in Access somewhat scarce. Thanks in advance for any help!
-Rod