Results 1 to 3 of 3
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    369

    Anyone used listview control in Access

    Hi, trying to set up a unbound listview control in Access but running into a few problems and
    can't get much info via Google. A lot of stuff my apply only to another platform (VB Net ?)


    code
    Code:
    Private Sub Form_Load()
        Dim thelistview As ListItem
        Dim i As Integer
        With ListView0
    
    
       .ListItems.Clear
            .ColumnHeaders.Clear
        '.items.Clear()   >>>>  Error
        .ColumnHeaders.Add , , , 300
        .ColumnHeaders.Add , , "Field2", 1000
        .ColumnHeaders.Add , , "s", 300
        .ColumnHeaders.Add , , "Field3", 4500
        .View = lvwReport
        .GridLines = True
        .FullRowSelect = True
        .Checkboxes = True
    
    
       '.SortOrder = lvwAscending
    
    
        For i = 1 To 30
            Set thelistview = .ListItems.Add
            
            thelistview.SubItems(2) = "Test " & i
            thelistview.SubItems(3) = "5"
            thelistview.SubItems(4) = "3rd Column"
        Next
     
     End With
     
    End Sub
    Main problem is the .Clear instructions are failing, each time the Form opens the listview gets more columns.


    The other things may be related to that, can anyone help me with that first? Thanks

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,421
    I learned a bit about ActiveX controls while working on an Access app for the Windows Media Player. It might be helpful here.
    You must have a VERY good reason to go thru this torture instead of using a native Access listbox.

    ListView-davegri-v01.zip

    End result:
    Click image for larger version. 

Name:	LVform.png 
Views:	24 
Size:	10.3 KB 
ID:	49381

    Don't know if you're aware, but adding the ActiveX control to the form exposes these methods:
    Click image for larger version. 

Name:	LVcode.png 
Views:	24 
Size:	78.3 KB 
ID:	49382

    You need this reference:
    Click image for larger version. 

Name:	LVrefs.png 
Views:	24 
Size:	23.1 KB 
ID:	49383

  3. #3
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    369
    Thanks Davegri, I will devour all that. I like the checkbox functionality -and the column resize, but you're right it is torture!
    I managed to make it behave after adding
    .ListItems.Clear .ColumnHeaders.Clear
    And I have the reference.
    Cheers

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to requery listview control from subform.
    By atzdgreat in forum Forms
    Replies: 8
    Last Post: 10-31-2019, 03:48 AM
  2. MS ListView Control for office 2013
    By moodhi in forum Forms
    Replies: 2
    Last Post: 10-19-2017, 04:23 PM
  3. ListView Control (ActiveX) in Ms.Access Form
    By ahmed_one in forum Access
    Replies: 18
    Last Post: 04-21-2015, 10:22 PM
  4. Replies: 1
    Last Post: 03-20-2013, 02:43 AM
  5. Filter listview
    By JJCHCK in forum Programming
    Replies: 2
    Last Post: 09-23-2011, 10:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums