Results 1 to 3 of 3

Thread: Addind records to a listview

  1. #1
    PORRASTAR
    Guest

    Addind records to a listview

    What is the code to add records from a recordset to a listview control?

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Code:
        rs.MoveFirst
         Do While Not rs.EOF
            'Replace the following line with the correct data
            ListView1.ListItems.Add , Key, Text, Icon, SmallIcon
            
            rs.MoveNext
        Loop
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. SQL = "SELECT name, type, webaddress FROM websites "
    2.         Set WebRs = WebDb.OpenRecordset(SQL, dbOpenDynaset)
    3.         'by setting a reference to the field name, VB does not have
    4.         'to iterate through the fields collection each time it goes
    5.         'through the loop
    6.         Set FieldName = WebRs.Fields("name")
    7.        
    8.         Do While Not WebRs.EOF
    9.          Set MyItem = lvWebSites.ListItems.Add(, , FieldName.Value)
    10.             MyItem.SubItems(1) = WebRs("type")
    11.             MyItem.SubItems(2) = WebRs("webaddress")
    12.             WebRs.MoveNext
    13.         Loop
    lvWebSites is my ListView control. FieldName is a form level variable dimensioned As Field. type and webaddress are fields in my Access database.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width