Results 1 to 4 of 4

Thread: Slight problem with ListView

  1. #1

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396

    Slight problem with ListView

    Hello Everyone
    I'm trying to use ListView to get contents of an Access Table into it...And I use the following code to do so...but while executing the statements I get an error- Invalid property Value
    Please help!!!!

    Dim Db As Database
    Dim Rs As Recordset
    Dim SQL As String
    Dim MyItem As ListItem
    Private Sub Form_Load()
    Set Db = OpenDatabase("d:\check\taws\data.mdb")
    SQL = "SELECT * FROM Audit "
    Set Rs = Db.OpenRecordset(SQL, dbOpenDynaset)
    Do While Not Rs.EOF
    Set MyItem = ListView1.ListItems.Add(, , Rs(0))
    MyItem.SubItems(1) = Rs(0)
    MyItem.SubItems(2) = Rs(1)
    'continue as above until all fields are accounted for
    Rs.MoveNext
    Loop
    Rs.Close

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    On what line do you get the error?

  3. #3

    Thread Starter
    Frenzied Member mxnmx's Avatar
    Join Date
    Dec 2001
    Location
    I'm back...now!!!
    Posts
    1,396
    On this line Hack, it says Invalid Property value..
    MyItem.SubItems(1) = Rs(0)

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    You have a minor issue here which can be easily fixed.
    VB Code:
    1. Set MyItem = ListView1.ListItems.Add(, , Rs(0))  'rs 0
    2. MyItem.SubItems(1) = Rs(0) ' rs 0
    3. MyItem.SubItems(2) = Rs(1)
    4. 'should be
    5. Set MyItem = ListView1.ListItems.Add(, , Rs(0)) rs 0
    6. MyItem.SubItems(1) = Rs(0) rs 1
    7. MyItem.SubItems(2) = Rs(1) rs 2
    8. 'etc

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