I figured out the solution.
Private Sub lstreps_ColumnClick(ByVal ColumnHeader As Object)
Dim oListItem As ListItem
Dim i As Integer
i = ColumnHeader.Index - 1
'date columns
If ColumnHeader.Index = 4 Or ColumnHeader.Index = 5 Or
ColumnHeader.Index = 6 Or ColumnHeader.Index = 7 _
Or ColumnHeader.Index = 10 Then
For Each oListItem In lstReps.ListItems
oListItem.SubItems(i) = _
Format$(oListItem.ListSubItems(i).Tag, _
"yyyymmddHHMMSS")
Next oListItem
End If
With lstReps
.SortKey = ColumnHeader.Index - 1
.Sorted = True
If .sortOrder = lvwAscending Then
.sortOrder = lvwDescending
Else
.sortOrder = lvwAscending
End If
End With
'date columns
If ColumnHeader.Index = 4 Or ColumnHeader.Index = 5 Or
ColumnHeader.Index = 6 Or ColumnHeader.Index = 7 _
Or ColumnHeader.Index = 10 Then
For Each oListItem In lstReps.ListItems
oListItem.SubItems(i) = _
CDate(oListItem.ListSubItems(i).Tag)
Next oListItem
End If
End Sub
Duane Hookom said:
You can always use code to update/change the Row Source of a list box.
--
Duane Hookom
MS Access MVP
Chuck said:
Also, the dates are stored as dates in the tables, but any data populated
in
a listview is stored in the listview as text.
Duane Hookom said:
Maybe go back to a standard list box with a SQL Row Source statement that
sorts on CDate([YourTextDate]).
--
Duane Hookom
MS Access MVP
I have started using the litview active x control vs. the typical
listbox.
I
have a sort function that works fine, but since all data is stored as
text
it
sorts dates incorrectly. Is there a work around for this??