|
-
Oct 10th, 2000, 11:48 AM
#1
I am trying to add all the contents from a ListBox to my Access Data Base. Right now, only the last item in my ListBox is written to my database.
Code:
Dim iX As Integer
Dim myArr()
For iX = 0 To lstInk2.ListCount - 1
lstInk2.ListIndex = iX
ReDim Preserve myArr(iX)
myArr(iX) = lstInk2.Text
Next iX
For iX = LBound(myArr) To UBound(myArr)
deMain.rsThermo!T_PMS = myArr(iX)
deMain.rsThermo.Update
Next iX
thank you for the help!
-
Oct 10th, 2000, 12:20 PM
#2
change the first line to this:
this will step backward through the listbox,
retrieving all the items..
Code:
Dim iX As Integer
Dim myArr()
For iX = (lstInk2.ListCount - 1) To 0 Step - 1
lstInk2.ListIndex = iX
ReDim Preserve myArr(iX)
myArr(iX) = lstInk2.Text
Next iX
For iX = LBound(myArr) To UBound(myArr)
deMain.rsThermo!T_PMS = myArr(iX)
deMain.rsThermo.Update
Next iX
-
Oct 10th, 2000, 12:23 PM
#3
_______
<?>
'try this
[code]
For iX = LBound(myArr) To UBound(myArr)
deMain.rsThermo.AddNew
deMain.rsThermo!T_PMS = myArr(iX)
deMain.rsThermo.Update
Next iX
[\code]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 10th, 2000, 01:13 PM
#4
Thanks for the help but I am still having problems.
1. When I used larryn's code, all that did was put the first occurance of the items in to the data base. Before it was doin the last occurance. Incediently, what will it look like (In Access) when there are multiple items in one field? I have a feeling that every occurance is overwriting a previous one.
2. HeSaidJoe's code is what influnced me this morning. I saw that he had posted the same reply a couple of days ago for someone else. My program bombs (Run time error) because of the ".AddNew" line. It bombs because this rountine is already part of an ".AddNew" routine. It actually blows up on the already existing ".Update" much later in the code.
Thank you for both of your help. I think I'm going keep trying. If you can add any more it would be greatly appreciated.
Thank You.
-
Oct 10th, 2000, 02:32 PM
#5
Maybe I'm being retarded or just plain stubborn. However, I am getting the same results with this code:
Code:
For iX = 0 To lstInk2.ListCount - 1
lstInk2.ListIndex = iX
ReDim Preserve myArr(iX)
myArr(iX) = lstInk2.Text
!T_PMS = myArr(iX)
.Update
Next iX
Again, I'm only getting the last occurance in my ListBox. I think that I am being stubborn, but that lousy .AddNew just bombs my program.
Can Access handle more than one entry in a field?
Example:
Red
White
Blue
Thank You Again.
-
Oct 10th, 2000, 05:00 PM
#6
let's try it again,
let's add a movenext to deMain
Code:
Dim iX As Integer
Dim myArr()
For iX = 0 To lstInk2.ListCount - 1
lstInk2.ListIndex = iX
ReDim Preserve myArr(iX)
myArr(iX) = lstInk2.Text
Next iX
For iX = LBound(myArr) To UBound(myArr)
deMain.rsThermo.AddNew
deMain.rsThermo!T_PMS = myArr(iX)
deMain.rsThermo.Update
deMain.rsThermo.MoveNext
Next iX
[Edited by larryn on 10-10-2000 at 06:09 PM]
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
|