|
-
Apr 3rd, 2000, 09:06 PM
#1
Thread Starter
Lively Member
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]
-
Apr 4th, 2000, 01:23 AM
#2
Fanatic Member
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!!)
-
Apr 4th, 2000, 07:56 AM
#3
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|