Results 1 to 3 of 3
  1. #1
    tmcrouse is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Apr 2009
    Posts
    169

    Combox list box


    I want to create a drop-down box where a user can select 1 or more of the drop-down items. I want the drop-down because it is much prettier on the form. I know a listbox you can set it up for 1 or more items, but to make it pretty you just show maybe the first item and then have to offer instructions on how to select 1, 2 or more items or all items in the list. I want to be able to have the drop-down so they can scroll through and pick 1 or more of the items, or all the items yet have it look pretty by just a small comboxbox. Is there a way to do this or do I have to do a listbox?

    I thought about a subform and doing that to where it is a one to many relationship but the end-users do not want that because it is another step they have to take................Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    The only way I know for a combobox to be multi-select is to be bound to a multi-value field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410
    You can do this with a List box but not a Combo box.

    A multi-select list box as June7 noted.

    I use this on a Form:
    Code:
    SELECT [VendorNumber] AS VendID, Last([VendorName]) AS Name FROM PO1_PurchaseOrderEntryHeader GROUP BY [VendorNumber] ORDER BY Last([VendorName])  UNION select " ALL" AS VendID, "ALL VENDORS" AS Name from PO1_PurchaseOrderEntryHeader;
    Then an Event Procedure on the Form to Export the select Vendors in a query using the IN clause.
    Code:
    Private Sub cmdRunReport_Click()
    On Error GoTo Err_cmdRunReport_Click
        Dim MyDB As Database
        Dim qdf As QueryDef
        Dim i As Integer, strSQL As String
        Dim strWhere As String, strIN As String
        Dim flgAll As Boolean
        
        Set MyDB = CurrentDb()
        
        strSQL = "SELECT * FROM PO1_PurchaseOrderEntryHeader"
        
        'create the IN string by looping thru the listbox
        For i = 0 To VendorSelector.ListCount - 1
            If VendorSelector.Selected(i) Then
                If VendorSelector.Column(0, i) = " All" Then
                    flgAll = True
                End If
                strIN = strIN & "'" & VendorSelector.Column(0, i) & "',"
            End If
         Next i
         
        'create the WHERE string, stripping off the last comma of the IN string
        strWhere = " WHERE [VendorNumber]in (" & left(strIN, Len(strIN) - 1) & ")"
        
        'if "All" was selected, don't add the WHERE condition
        If Not flgAll Then
            strSQL = strSQL & strWhere
        End If
        
        MyDB.QueryDefs.Delete "PO1"
        Set qdf = MyDB.CreateQueryDef("PO1", strSQL)
        
        DoCmd.RunMacro "Process"
    
    
    Exit_cmdRunReport_Click:
        Exit Sub
        
    Err_cmdRunReport_Click:
        If Err.Number = 3265 Then   '*** if the error is the query is missing
            Resume Next             '*** then skip the delete line and resume on the next line
        ElseIf Err.Number = 5 Then
            MsgBox "You must make at least one selection"
            Resume Exit_cmdRunReport_Click
        Else
            MsgBox Err.Description      '*** write out the error and exit the sub
            Resume Exit_cmdRunReport_Click
        End If
    
    
    End Sub

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

Similar Threads

  1. Forms, Combox Edit List Option
    By RoundTrip in forum Access
    Replies: 7
    Last Post: 03-02-2014, 09:13 PM
  2. Combox box Item List
    By engr_saud1 in forum Access
    Replies: 1
    Last Post: 04-04-2013, 06:50 AM
  3. Replies: 1
    Last Post: 04-17-2012, 12:27 PM
  4. Combox Box Help
    By BLD21 in forum Reports
    Replies: 3
    Last Post: 09-22-2011, 01:06 PM
  5. Combox Box Outputs the ID in text
    By Alexandre Cote in forum Queries
    Replies: 3
    Last Post: 07-20-2010, 08:47 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