move items between 2 listboxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Neruda
    New Member
    • Mar 2017
    • 72

    move items between 2 listboxes

    Hi,
    Have 2 listboxes side by side and 1 button on a form.
    One listbox(A) has a list of products. The other empty(B).
    The user need to select a product from A and move it to the empty one (B) with the button or double click. Once the desired number of products are in B, a code will do something with the list in B.

    You might have come across this, I was wondering if you had some advice how to keep it simple given that:

    -would be nice to select many item at once in A (maybe in extended mode?)

    -if I select items in A that are already in B, then a message would pop up

    or

    -when a product is moved to B it disappears from A.

    Thanks
  • cactusdata
    Recognized Expert New Member
    • Aug 2007
    • 223

    #2
    All you need is to loop the items of one of the listboxes.
    For each selected item, add it to the items of other listbox, then delete it.

    Comment

    • Neruda
      New Member
      • Mar 2017
      • 72

      #3
      I ended up using two listboxes (was considering 2 subforms), a few queries in vba and a dummy field with Yes/No values in tbl_Products.

      All the products in the left listbox have a "Yes" in the dummy field (in the table). When an item is double clicked it gets marked as "No" in the dummy field. Both listboxes are now requeried and the item double clicked is in the second listbox and has disappeared from the first.

      Also I explored doing it with querydef but I spent way too much time on this omg.

      Thank you !

      Comment

      Working...