-
How do I get a listview in report view to sort in ascending or descending order by the column that is clicked. I tried:
Code:
Private Sub Listview_ColumnClick()
With Listview
If (.SortOrder = lvwAscending) Then
.SortOrder = lvwDescending
Elseif (.SortOrder = lvwDescending) Then
.SortOrder = lvwAscending
Endif
End With
End Sub
but that sorts by the first column no matter which column you click on. Do I have to rearrange the column indexes whenever a column is clicked or what?
-
-
Try this:
Code:
'Author: Cierra Computers & Consulting
'Origin: http://www.planet-source-code.com
'Purpose: ListView Column Sort Function
'Version: VB5+
Public Sub SortListView(ctlListView As ListView, intColulunHeaderIndex As Integer)
ctlListView.Sorted = True
ctlListView.SortKey = intColulunHeaderIndex - 1
If ctlListView.SortOrder = lvwAscending Then
ctlListView.SortOrder = lvwDescending
Else
ctlListView.SortOrder = lvwAscending
End If
End Sub