I have a listview in ms access 2003.
I need to be able to order the columns when I select it, but I get an error
message. This is the code I am using:
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As
MSComctlLib.ColumnHeader)
If Not ListView1.Sorted Then
ListView1.SortOrder = lvwAscending
ListView1.ColumnHeaders.Item(1).Icon = 1
Else
If ListView1.SortOrder = lvwAscending Then
ListView1.SortOrder = lvwDescending
ListView1.ColumnHeaders.Item(1).Icon = 2
Else
ListView1.SortOrder = lvwAscending
ListView1.ColumnHeaders.Item(1).Icon = 1
End If
End If
ListView1.SortKey = ColumnHeader.Index - 1
ListView1.Sorted = True
End Sub
I have one more problem with this. I want to be able to change the data in
one of those cells. How can I do it?
Regards, Lina
TC - 04 Jan 2006 09:13 GMT
What is the message & on what line do you get it.
TC
Alex Dybenko - 04 Jan 2006 10:28 GMT
Hi,
to avoid some possible porblems with activex controls - better to declare a
class level variable:
private MyListViewObject as MSComctlLib.ListView
set it to your control in form's Load event:
set MyListViewObject=me.ListViuew1.Object
and then use it in your code:
MyListViewObject.SortOrder = lvwAscending
etc
HTH

Signature
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
>I have a listview in ms access 2003.
> I need to be able to order the columns when I select it, but I get an
[quoted text clipped - 26 lines]
>
> Regards, Lina
Lina Manjarres - 04 Jan 2006 18:15 GMT
Alex, thanks a lot, this help me so much!!!
> Hi,
> to avoid some possible porblems with activex controls - better to declare a
[quoted text clipped - 43 lines]
> >
> > Regards, Lina
Naresh Nichani - 04 Jan 2006 13:19 GMT
This is come code I have used in VB6
Private Sub lstViewModel_ColumnClick(ByVal ColumnHeader As
MSComctlLib.ColumnHeader)
Dim strSortOrder As String
Dim iIndex As Integer
On Error GoTo errHandler
iIndex = ColumnHeader.Index
If ColumnHeader.Tag = "A" Or ColumnHeader.Tag = "" Then
strSortOrder = "A"
Else
strSortOrder = "D"
End If
If strSortOrder = "A" Then
lstViewModel.SortOrder = lvwAscending
Else
lstViewModel.SortOrder = lvwDescending
End If
lstViewModel.SortKey = iIndex - 1
lstViewModel.Sorted = True
If strSortOrder = "A" Then
lstViewModel.ColumnHeaders(iIndex).Tag = "D"
Else
lstViewModel.ColumnHeaders(iIndex).Tag = "A"
End If
End Sub
Regards,
Naresh Nichani
Microsoft Access MVP
>I have a listview in ms access 2003.
> I need to be able to order the columns when I select it, but I get an
[quoted text clipped - 26 lines]
>
> Regards, Lina