Moving data from one listbox to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Arya Kurumathur
    New Member
    • May 2013
    • 2

    Moving data from one listbox to another

    Hi,

    So i have 2 listboxes, lstSource and lstDestination, lstSource takes it data from Resource table.

    What i need to do is move list items one by one from lstSource to lstDestination and vice versa.

    What i am doing right now is this,

    Code:
    Private Sub cmdMoveToList2_Click()
       On Error GoTo Err_cmdMoveToList1_Click
     
    If Me.lstSource.ListIndex >= 0 Then
    
        Me.lstDestination.AddItem Me.lstSource.ItemData(Me.lstSource.ListIndex)
        End If
     
    Exit_cmdMoveToList1_Click:
        Exit Sub
     
    Err_cmdMoveToList1_Click:
        MsgBox Err.Description
        Resume Exit_cmdMoveToList1_Click
    And the same for lstDestination to lstSource.

    The problem i am facing is that when i click on the icon to move from lstSource to lstDestination it adds not the ResourceName(wh ich is the list value) but the corresponding Resource ID (which is the primary key of Resource Table).


    And also since the row source type for lstSource is table/query, lstDestination to lstSource moving is not happening.

    Pls advise.

    Thanks,
    Arya
    Last edited by Rabbit; May 2 '13, 03:32 PM. Reason: Fixed code tags
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    The Method you are using is more than likely picting up the Value of the Bound Column, try:
    Code:
    Me.lstDestination.AddItem Me.lstSource.Column(1)

    Comment

    • gorijaj
      New Member
      • Sep 2015
      • 1

      #3
      Firstly thank you very much.

      While I am trying this code only single columns is moving to second listbox. for ex listbox one value is empno, empname,empcoun try. while I try this code only empno is visible in listbox2

      Comment

      Working...