troubleshooting Question

VB6 - Listview headers don't show and Subitems are missing

Avatar of ljcor
ljcorFlag for United States of America asked on
Visual Basic Classic
7 Comments1 Solution685 ViewsLast Modified:
As a result of the code below, the Listview control shows only the Project ID for each item in the Access table.  Also, although I did extablish a header for each of the fields (4 total) using the Property manager, none of them show up at all.  I thought they would automatically populate but I now imagine that they have to be in code in some way.

In stepping through the code I can see that all 4 items of data are brought in from Access established in the sorted order of my query.
Private Function PopulateList(lView As Control) As Boolean
 
    'Add items from a recordset to the Listview control.
    Dim lItem As ListItem
    Dim ProjID As Variant, BizID As Variant, ProjVer As Variant, ProjDate As Date
    
    Set db = Workspaces(0).OpenDatabase(MDBPath & "ProjectEvalDB.mdb")
    Set rs = db.OpenRecordset("qryProjectList")
 
    With lView
        .ListItems.Clear
        .Sorted = False
        
        If rs.RecordCount > 0 Then rs.MoveFirst Else Exit Function
        
        Do Until rs.EOF                         'get the data fields
            ProjID = rs.Fields("Project ID")
            BizID = rs.Fields("Business Unit ID")
            ProjVer = rs.Fields("Evaluation Version")
            ProjDate = rs.Fields("Evaluation Date")
            
            'Add the item
            Set lItem = .ListItems.Add(, , ProjID)
            lItem.SubItems(1) = BizID
            lItem.SubItems(2) = ProjVer
            lItem.SubItems(3) = ProjDate
            
            rs.MoveNext
        Loop
        
        rs.MoveFirst
        lView.ListItems(1).EnsureVisible
        .Refresh
    End With
    PopulateList = True
End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros