'method or data member not found in vb6?

This is my code

Sub filllistview()
  Dim itmX As ListItem

  Main

  rs.Open " select * from hatw order by id desc  ", dbconn, 3, 2

  If Not rs.EOF Then
    ListView1.ListItems.Clear
    rs.MoveFirst

    Do While Not rs.EOF
      Set itmX = ListView1.ListItems.Add(1, , rs!id)
      itmX.ListSubItems.Add , , rs!no_of_text
      itmX.ListSubItems.Add , , rs!date_of_text
      itmX.ListSubItems.Add , , rs!Title
      rs.MoveNext
    Loop
  Else
    ListView1.ListItems.Clear
  End If

  rs.Close
  Set rs = Nothing
End Sub

When I hit F5 this error occurs:

method or data member not found

The error highlights this statement:

ListView1.ListItems.Clear 
vb6


Solution 1:[1]

Your hunch about needing to add a reference to your project seems to be correct. According to the documentation you need to add a reference to MSCOMCTL.OCX. In the Excel VBA editor reference dialog I had to search a bit for it (it wasn't a predefined reference) but found it on my machine at: C:\Windows\SysWOW64\MSCOMCTL.OCX. Once I found the control it appeared as Microsoft Windows Common Controls 6.0 (SP6) in the reference list. Perhaps it is listed automatically as that already in Access. As soon as I added the reference lines like

Dim LV as ListView

compile cleanly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Coleman