Results 1 to 15 of 15
  1. #1
    LarryJ is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2023
    Posts
    18

    List box question

    Here is what I am trying to do:



    I have a list box with 40 items and I want to be able to click them and copy them into another list box, without losing what is in the destination list box. For example, the first item I click would be copied to the destination and when I click other items they would be copied as well without erasing the contents of the destination. I'm wondering if the destination needs to be something other than a list box. Any suggestions?

  2. #2
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,578
    Why would you need to do this?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    What is the Row Source property of both listboxes and what is the Row Source Type property of both listboxes
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,451
    Would also ask - if a user has ‘copied’ an item rather than ‘move’ an item - can they copy it again?

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,024
    Quote Originally Posted by mike60smart View Post
    Why would you need to do this?
    Common function Mike?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,829
    I'd say not all that uncommon, especially if you move the items from one to the other but I wonder about the copying thing. Why not just multi-select if you're going to copy? I have done this from a multi-select listbox then moved the selected items to another with a button click rather than double clicking each list item.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    LarryJ is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2023
    Posts
    18
    The idea is to take the roster of a baseball team and create their starting lineup, which is why I'm wondering if the destination needs to be something other than a list box. The origin box is filled by clicking the team name in another box and executing a query to retrieve the roster (select * from...). From that, I want to be able to click on the players and create the batting order.

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,745
    LarryJ,

    Watch this older video from DataPig (now resurrected) re moving items from listbox1 to listbox2. It may give some insight.

    listbox1-- could be team roster
    listbox2-- batting lineup
    Last edited by orange; 08-13-2023 at 10:24 AM. Reason: additional info

  9. #9
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,578
    Probably but I was just curious as to the process.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,829
    The idea is to take the roster of a baseball team and create their starting lineup
    Then you need to ensure that the same player cannot be added more than once. How you want to work with the subset of items should probably be the deciding factor as to whether or not to use a second listbox, which can be fine in a lot of cases. Lots of things you could do. One might be to use a staging table where you delete all records before populating with your list choices. Easier perhaps than trying to work with a value list from the 2nd listbox if you want something like a report from your selections.

    EDIT - Forgot to say that the table could also handle not allowing the same item to be added again.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    Here's a picklist class.
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  12. #12
    LarryJ is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2023
    Posts
    18
    Well, this is odd. In the form in your zip file, everything works. But I'm getting a user defined type not defined error when I try to use it in a new form, which seems odd since it works just fine inside what you sent.

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,829
    user defined type not defined
    Most likely you are missing a reference in your own db that the db has where the form works.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,656
    Did you add a reference to Microsoft Scripting Runtime?

    I believe that's the error if you didn't.

    Later versions of that demo are late bound so no reference needed but I didn't have a newer one handy when I posted.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  15. #15
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,024
    Quote Originally Posted by LarryJ View Post
    Well, this is odd. In the form in your zip file, everything works. But I'm getting a user defined type not defined error when I try to use it in a new form, which seems odd since it works just fine inside what you sent.
    Did you read the code, the form? It says you need a certain reference?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Not In List Event Question?
    By mrmims in forum Programming
    Replies: 3
    Last Post: 07-23-2014, 05:49 AM
  2. List Box Question
    By MikeAllen in forum Access
    Replies: 3
    Last Post: 08-20-2012, 07:29 AM
  3. Not in list Question
    By Mclaren in forum Programming
    Replies: 1
    Last Post: 03-03-2012, 08:46 PM
  4. New to VBA - Textbox/ List question
    By dreamnauta in forum Programming
    Replies: 6
    Last Post: 12-21-2011, 01:41 PM
  5. Question about Value List
    By Buakaw in forum Access
    Replies: 3
    Last Post: 02-18-2011, 04:25 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums