Results 1 to 7 of 7
  1. #1
    BeStout is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    2

    Multiple Selections in a Combo Box


    I'm trying to essentially create a "select all" option in my combo box and then when I press a button on my form, I'd like each value from the combo box to be a separate entry in a table.

    Specifically, I am selecting a supplier in another combo box, which narrows down the part numbers in the combo box I am having trouble with. Then I'd like to select all of the part numbers and have a row for each in my datasheet.

    Is this possible? I really appreciate any help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Your combo is based on an SQL statement. You could replicate this statement using VBA and retrieve the same records logically, then apply the data retrieved to your form's controls.

    There is not a multi select option for combos. There is a multi select option for List Box controls.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    First, combo boxes don't have a multi-select option - you have to use a list box.

    From what I can see, there is no "select all" option for selecting items in a list box. What you could do is put a "Select All" checkbox on your form, near the list box somewhere, and then the code behind the command button could process all the list box rows if "Select All" was checked, otherwise it would check each listbox row to see if it was selected (more-or-less normal processing).

    HTH

    John

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The would really work better as a table of values rather than a multi select combo.
    The user selects items in a list, they append to a table.
    This table of selections is linked to the main data table to retrieve the picked items.
    No code, only queries. Select all appends all items query. Select 1 appends 1 item query. A query to empty the list to start fresh. A query to delete 1 item.

    Click image for larger version. 

Name:	pick3-states.png 
Views:	14 
Size:	22.4 KB 
ID:	17179

  5. #5
    BeStout is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    2
    John,

    Thanks for the help. Is there any way you could help me with what that code for the check box would be?

    Brad

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You don't need any code behind the checkbox itself, you only need to check its value.

    Supposing the checkbox is called SelectAll, you might have something like this:

    Code:
    '
    ' Scan through all the listbox items
    '
     For J = 0 To listboxname.ListCount - 1
          '
          ' If the listbox item is selected OR the Select All box has been checked
          '
          If me!SelectAll  or listboxname.Selected(J) Then
          '
          '  Process the list item
          '
          End If
      Next J
    replace listboxname with the actual name of your listbox control.

    You would probably use this in the code for a command button.

    HTH

    John

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

Similar Threads

  1. Replies: 21
    Last Post: 06-13-2013, 06:51 AM
  2. Replies: 3
    Last Post: 01-21-2013, 12:57 AM
  3. Replies: 5
    Last Post: 01-15-2013, 01:27 PM
  4. Replies: 2
    Last Post: 05-27-2011, 08:12 AM
  5. Replies: 1
    Last Post: 03-02-2009, 11:54 AM

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