Listview modify

L

Lina Manjarres

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
 
A

Alex Dybenko

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
 
N

Naresh Nichani

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
 
L

Lina Manjarres

Alex, thanks a lot, this help me so much!!!

Alex Dybenko said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top