Results 1 to 3 of 3

Thread: Putting Listitems from a listview into a database table?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78
    Hi,

    I am in need of information on how to arrange the listitems in a listview to be automatically added into a table in a database. I have the following code but get an error back of Out Of Bounds.

    Code:

    Dim myRs As Recordset, i As Integer

    Set myRs = pDatabase.OpenRecordset("Temp", dbOpenTable)


    myRs.AddNew
    myRs!RDate = LsvWDetails.ListItems.Item(1)
    myRs!RLKnee = LsvWDetails.ListItems.Item(2)
    myRs!RRKnee = LsvWDetails.ListItems.Item(3)
    myRs!RLThigh = LsvWDetails.ListItems.Item(4)
    myRs!RRThigh = LsvWDetails.ListItems.Item(5)
    myRs!RBust = LsvWDetails.ListItems.Item(6)
    myRs!RPlus = LsvWDetails.ListItems.Item(7)
    myRs.Update
    myRs.Close


    Now I get the Out of bounds code on item(2) - (7). Any ideas on how to change this so it will work will be greatly appreciated and Thanks in advance for any help.

    Mike

    ps: sorry stevie i took out the for loop

    [Edited by Spawny on 04-05-2000 at 07:50 AM]

  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    I may be wrong about this (at home now and VB at work), but I think you should be referencing the subitems not items.
    Something along the lines of :

    Code:
    Dim myRs As Recordset, i As Integer 
    
    Set myRs = pDatabase.OpenRecordset("Temp", dbOpenTable) 
    
    For i = 1 To LsvWDetails.ListItems.Count 
      myRs.AddNew 
    
      myRs!RDate = LsvWDetails.ListItems.Item(1) 
      myRs!RLKnee = LsvWDetails.ListItems.Item.Subitems(1) 
      myRs!RRKnee = LsvWDetails.ListItems.Item.Subitems(2) 
      myRs!RLThigh = LsvWDetails.ListItems.Item.Subitems(3) 
      myRs!RRThigh = LsvWDetails.ListItems.Item.Subitems(4) 
      myRs!RBust = LsvWDetails.ListItems.Item.Subitems(5) 
      myRs!RPlus = LsvWDetails.ListItems.Item.Subitems(6) 
      
      myRs.Update 
      myRs.Close 
    Next
    Hope this helps (and is correct!!)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 1999
    Location
    Brisbane, Qld, Australia
    Posts
    78
    hey Stevie,

    Thanks that was very close i had to just add in this so it worked:

    myRs!RComments = LsvWDetails.ListItems(1).SubItems(1)

    thanx for your help

    [Edited by Spawny on 04-06-2000 at 07: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
  •  



Click Here to Expand Forum to Full Width