-
HELP!! Delete duplicates from listview
I have several listview boxes which are filled via a stored procedure that joins several tables. I do not want to retrieve this data using separate stored procedures because I don't want to make that many trips to the database.
As a result of the joins, some listviews contain duplicates. I need to be able to remove those duplicates in each listview box.
I tried searching the Internet for what I thought would be an easy item to find. I am coming up with Zip!! (or code that works at any rate).
Can someone give me a code example of how this would be done?
Any help will be greatly appreciated!
-
Try this.
Code:
Private Sub Command1_Click()
Dim i As Long, j As Long
With ListView1
For i = 1 To .ListItems.Count
For j = .ListItems.Count To (i + 1) Step -1
If .ListItems(j) = .ListItems(i) Then
.ListItems.Remove j
End If
Next
Next
End With
End Sub
-
 Originally Posted by Angelo88
Try this.
Code:
Private Sub Command1_Click()
Dim i As Long, j As Long
With ListView1
For i = 1 To .ListItems.Count
For j = .ListItems.Count To (i + 1) Step -1
If .ListItems(j) = .ListItems(i) Then
.ListItems.Remove j
End If
Next
Next
End With
End Sub
Thank you so much, Angelo88. That solved the problem beautifully!!
-
... or look at DISTINCT in your SELECT
-
Thanks for your response. I couldn't in this particular instance because I had many tables that were joined.
-
Suggest all you need is to put 'DISTINCT' after the first 'SELECT' ....
Greg
Similar Threads
-
By vb_programmer in forum VB Classic
Replies: 1
Last Post: 09-16-2006, 07:37 PM
-
By DrunkMunk in forum VB Classic
Replies: 1
Last Post: 06-09-2006, 05:21 PM
-
By Mike Kopa in forum Database
Replies: 3
Last Post: 12-31-2000, 11:03 AM
-
By Emmanuel Durand in forum VB Classic
Replies: 0
Last Post: 05-10-2000, 11:55 AM
-
By Emmanuel Durand in forum VB Classic
Replies: 0
Last Post: 05-10-2000, 11:55 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|