Results 1 to 3 of 3
  1. #1
    crimson is offline Novice
    Windows 7 Access 2013 32bit
    Join Date
    Nov 2010
    Posts
    11

    Filter query through a multiple choice list box

    Hi,
    I have a form with a list box. The list box is set for simple multiple choices. Entries for the list box are taken from a table. Each record in the table has a unique text column (name of the sample) and corresponding ID. The list box shows only the text column. A query summarizes results of calculations, which are based on the data from the table. I would like to be able to filter the query based on the list box. E.g., when a user marks five entries in the list box and clicks a button the query should popup, filtered only to records marked in the list box. How to achieve that?



    Thank you in advance
    Regards

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    You've just about described it already

    Add code to the button click event to run a query or SQL equivalent
    In your query / SQL, set filter criteria for the field in your listbox and set it to Forms!YourFormName!Form.ComboBoxName

    That will get the bound column - which is usually hidden.
    Columns are zero based so if your text field is the 3rd column use Forms!YourFormName!Form.ComboBoxName.Column(2)

    Replace form and combo names with your own
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    If you want to filter for the 5 selected items, this requires code that loops through the listbox selection. Review http://allenbrowne.com/ser-50.html
    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.

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

Similar Threads

  1. Making a multiple choice list searchable
    By dwheatley in forum Queries
    Replies: 8
    Last Post: 12-13-2017, 03:41 AM
  2. Replies: 7
    Last Post: 09-14-2017, 02:24 AM
  3. Replies: 0
    Last Post: 03-19-2017, 01:29 PM
  4. Replies: 1
    Last Post: 03-03-2016, 05:23 PM
  5. Replies: 5
    Last Post: 04-11-2012, 06:52 PM

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