Results 1 to 7 of 7
  1. #1
    pooldead is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    26

    Help Adding ComboBox Selection into ListBox Column

    I have a form with multiple combo boxes and a list box with multiple columns. My end goal is, for example, to have the selection from combobox1 added to listbox column 1. The code I have so far that work is:

    Me.listbox.additem (me.combobox1)

    I have been playing with the .column property, but every time I run it, it tells me I'm either not using the property correctly or that it isn't supported. I also tried a with statement as:

    With .me


    With .listbox
    .additem (combobox1)
    .column(0)

    Any help is appreciated!

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    you're saying this works Me.listbox.additem (me.combobox1)?
    then try
    Me.listbox.additem (me.combobox1.column(0))
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Further to Miron's suggestion, can you tell us in simple terms why you need this? I'm curious.

  4. #4
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    I assume you want each combo box to show as a column in the listbox. See attached. Default option in the code to restrict to one row in listbox.
    Attachment 39118

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by orange View Post
    Further to Miron's suggestion, can you tell us in simple terms why you need this? I'm curious.
    Good point. Why not just put the combo data in the listbox and select it from there?

  6. #6
    pooldead is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    26
    I have the combo boxes setup to provide options for users to select. I need to allow them to select multiple options, which will then be compiled in the list box and added to a user table with the click of one button. I have the rest of the code for the form working except this. I did try Micron's suggestion, however if I enter a value other than .column(0), it tells me "invalid use of null" which is not used in that particular sub.

    My backup option is to create 5 list boxes and stack them next to each other, and direct each combo to its corresponding list box, but I was hoping to find a bit more elegant solution.

  7. #7
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    The null message likely means that for that selection, the specified column contains no value. Regardless, you can do as you describe without the combos. Whether you need 2 list boxes or not depends on how it needs to work. Maybe all the chosen items from one list gets written to the table. Maybe 1 to provide the list and 1 to receive the chosen items from which you then write to the table. 5 combos is very likely the wrong move.

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

Similar Threads

  1. Replies: 5
    Last Post: 06-15-2018, 02:08 AM
  2. Replies: 3
    Last Post: 01-20-2017, 02:25 PM
  3. Replies: 2
    Last Post: 01-20-2017, 10:26 AM
  4. Combobox selection populates Listbox
    By Thompyt in forum Programming
    Replies: 9
    Last Post: 09-24-2015, 01:55 PM
  5. Replies: 1
    Last Post: 09-10-2012, 11:21 PM

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