Results 1 to 6 of 6

Thread: List Box Question

  1. #1
    Guest

    Question

    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!

  2. #2
    Guest
    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

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    '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

  4. #4
    Guest
    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.

  5. #5
    Guest
    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.

  6. #6
    Guest
    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
  •  



Click Here to Expand Forum to Full Width