How to move multiple columns from list box to list box?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bknabl
    New Member
    • May 2010
    • 19

    #1

    How to move multiple columns from list box to list box?

    I have two list boxes like so:



    And the following code:

    Code:
    Private Sub MoveListItem(lstFrom As ListBox, lstTo As ListBox)
         lstTo.AddItem (lstFrom.Value)
         
    End Sub
    
    
    
    Private Sub lstPartNumberLookup_DblClick(Cancel As Integer)
    MoveListItem Me.lstPartNumberLookup, Me.lstBuildOrder
    End Sub
      
    Private Sub lstBuildOrder_DblClick(Cancel As Integer)
        MoveListItem Me.lstBuildOrder, Me.lstPartNumberLookup
    End Sub
    When I double click the first list box, only the bound column is transferred into the list box below it. How can I get all of the columns to transfer over?

    This is in Access 2003. Thanks in advance!
  • jimatqsi
    Moderator Top Contributor
    • Oct 2006
    • 1293

    #2
    I am editing this message because I think the code is incorrect. I can't get it to work and can't find an alternate method that works in Access 2003.

    Jim

    Ignore all the below stuff

    Try this

    Code:
    dim intCount as integer
    for each intCount in me.listBuildOrder.List
    MoveListItem Me.lstBuildOrder, Me.lstPartNumberLookup
    next
    That will iterate through all the items in the listbox

    Jim
    Last edited by jimatqsi; Jun 23 '10, 06:24 PM. Reason: incorrect solution

    Comment

    • bknabl
      New Member
      • May 2010
      • 19

      #3
      me.listBuildOrd er.List returns a compile error: Method or Data member not found

      Edit: Thanks for the effort Jim. It was appreciated. Hopefully I can figure something out with this soon.

      Comment

      • patjones
        Recognized Expert Contributor
        • Jun 2007
        • 931

        #4
        I think you are both pretty close to getting this. When you use AddItem to add a line to a list box across multiple columns, the column entries need to be separated by a ";" as in lst.AddItem col1 & ";" & col2 & ";" & col3 and so on.

        In your particular case, I think you just need to build a string out of the columns from the line the user picks, and then simply pass that string into MoveListItem.

        Pat

        Comment

        Working...