[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2225
  • Last Modified:

ListView_ColumnClick User-defined type not defined

Hi,

i have added a form with a listview to my to a MS Project solution im using the reportview, and this is ok.

Then i want to add a columnclick event to sort data when clicking on a header, but i get a warning when i try to put on the Listview_Columnclick event: User-defined type not defined?
code:
Private sub ListView1_ColumnClick(Byval ColumnHeader As MSComctlLib.ColumnHeader)
<code>
End Sub

Open in new window

0
Torsleff-Experten
Asked:
Torsleff-Experten
  • 3
  • 2
1 Solution
 
Jeffrey CoachmanMIS LiasonCommented:
Is there a reason why you did not post the most important thing? ...
The code itself?
;-)

The most basic cause for this error is not having the correct libraries loaded.

So check your code references and make sure you have included all needed references.
Also check for any that say: MISSING.

;-)

JefCoachman
0
 
Torsleff-ExpertenAuthor Commented:
this is missing MSComctlLib, i think i know whats wrong using vba i Project 2003 you have to add the Listview to the toolbox, when i first made this i did that.

Then i exported the form with the Listbox, to open the entepriseglobal file and then ad the form to the enterpriseglobal.

Then i got the problem, i thing i have to open the enteroriseglobal file and add the listbox to the toolbox, else i dont know how to add MSComctlLib to the solution.

i cant find MSComctlLib in the referencelist.
0
 
Torsleff-ExpertenAuthor Commented:

when debugging codesnippet i get this error
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:

User-defined type not defined
---------------------------
OK   Help  
---------------------------

When i try to find the definition to MSComctlLib i get this error
---------------------------
Microsoft Visual Basic
---------------------------
Identifier under cursor is not recognized
---------------------------
OK   Help  
---------------------------

So i cant get the ListView_ColumClick working, and i cant find MSComctlLib in the referencelist?

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    Dim intSortKey As Integer
 
    If ColumnHeader.Index = 2 Or ColumnHeader.Index = 5 Then
        intSortKey = ColumnHeader.Index - 2
    Else
        intSortKey = ColumnHeader.Index - 1
    End If
 
    ListView1.Sorted = True
    If Not ColumnHeader.Index = 4 Then
        If ListView1.SortKey = intSortKey Then
            If ListView1.SortOrder = lvwAscending Then
                ListView1.SortOrder = lvwDescending
            Else
                ListView1.SortOrder = lvwAscending
            End If
        Else
            ListView1.SortKey = intSortKey
            ListView1.SortOrder = lvwAscending
        End If
    Else
        ListView1.Sorted = False
        SendMessage ListView1.hWnd, _
                      LVM_SORTITEMS, _
                      ListView1.hWnd, _
                      AddressOf CompareDates
    End If
End Sub
 
 
Private Sub UserForm_Initialize()
'**************************************************
' Dato: 02-11-08
' Forfatter: Torben Nielsen
' Opretter liste over mulige valg af Ressourcer
'**************************************************
    Dim rc As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim strSQL As String
    Dim i As Integer
    
    On Error GoTo HaveError
    strSQL = "exec HTMSGetPublishLastStatus"
    
    rc.Open gcsSQL
    rs.Open strSQL, rc
    'ListView1.View = lvwReport
    With ListView1
        .ColumnHeaders.Clear
        .ListItems.Clear
        .View = 3 'lvwReport
        .FullRowSelect = True
        .Gridlines = True
        .ColumnHeaders.Add , , "ProjectID", 0
        .ColumnHeaders.Add , , "ProjectID", 45
        .ColumnHeaders.Add , , "Project Name", 220
        .ColumnHeaders.Add , , "DateSort", 0
        .ColumnHeaders.Add , , "Last published", 95
        .ColumnHeaders.Add , , "Status AX", 45
        i = 0
        
        While Not rs.EOF
            i = i + 1
            .ListItems.Add , , Format(rs!PROJ_ID, "000000") 'TON to sort Number correct
            .ListItems(.ListItems.count).SubItems(1) = rs!PROJ_ID
            .ListItems(.ListItems.count).SubItems(2) = rs!PROJ_NAME
            .ListItems(.ListItems.count).SubItems(3) = Format(i, "000000") 'TON to sort Dates correct
            .ListItems(.ListItems.count).SubItems(4) = rs!WPROJ_LAST_PUB
            .ListItems(.ListItems.count).SubItems(5) = rs!otype
            rs.MoveNext
        Wend
        .SortOrder = lvwAscending
        .SortKey = 2
        .Sorted = True
    End With
     
    rs.Close
    rc.Close
    Exit Sub
 
HaveError:
    MsgBox Prompt:="Error in frmPublishInfo, UserForm_Initialize: " & i & " " & Err.number & " " & Err.Description
End Sub

Open in new window

0
 
Torsleff-ExpertenAuthor Commented:
I solved the problem by reestablishing the reference to MSComctl.OCX file
0
 
Jeffrey CoachmanMIS LiasonCommented:
;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now