Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview sort 2

Status
Not open for further replies.

guitardave78

Programmer
Sep 5, 2001
1,294
GB
Hey hey i'm back
I now have my listview with small icons , populated from an access database and i can sort it using

Public Sub LV_ColumnSort(ListViewControl As ListView, Column As ColumnHeader)
With ListViewControl
If .SortKey <> Column.Index - 1 Then
.SortKey = Column.Index - 1
.SortOrder = lvwAscending
Else
If .SortOrder = lvwAscending Then
.SortOrder = lvwDescending
Else
.SortOrder = lvwAscending
End If
End If
.Sorted = -1
End With
End Sub

But i would like to sort the date properlly.
I will explain
The date is sent to the database as MM/DD/YYYY HH:MM:SS

but to sort it nicely it has to be swaped to YYYY MM DD
so that they order in most recent to oldest

and that looks a bit cack. Any way of doing this without having to requery the database?
 
Add a hidden column for the same date field but formated as yyyy/mm/dd.
 
You need to add some extra logic so that when the ColumnIndex references the date column you add an offset to the index so it sorts on the hidden column.

Paul Bent
Northwind IT Systems
 
Thank you!!!!!

I was tring to change the column name and all sorts!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top