Results 1 to 2 of 2
  1. #1
    accessuser45 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    1

    Unhappy 2 multi-select listboxes used as criteria for query

    Hi, I have created a form with 2 unbound multi-select listboxes and want to run a query based on what was selected in both listboxes. I know I need VB code to run this but can't seem to find the right code. (I am new to VB)


    Please help!!

  2. #2
    always404 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2013
    Posts
    19
    There is a lot of flexibility with VBA but I used a button that when clicked ran this code:

    Me.Filter = "[YourField] = '" & ListBox.Value & "' AND " & "[YourBoolean] = YourBoolean.Value"

    Me.Filter is the object that filters the form.

    [YourField] is the field in your table/form that you want filtered
    ListBox.Value is the control holding the value you want to filter by

    [YourBoolean] is if you want the secondary filter criteria to be based on a Yes/No from your table, but you can just use a second text field here if you want.
    YourBoolean.Value is the value stored in the control that you wish to be your secondary filter criteria.

    I hope that was clear.

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

Similar Threads

  1. Replies: 6
    Last Post: 05-15-2013, 03:36 PM
  2. Replies: 6
    Last Post: 11-02-2012, 12:48 PM
  3. Replies: 5
    Last Post: 08-02-2012, 09:44 AM
  4. Multi-Select List Box as Criteria in Query
    By broadwat in forum Queries
    Replies: 6
    Last Post: 09-19-2011, 07:47 AM
  5. Passing Multi Select string to Query criteria
    By oleBucky in forum Queries
    Replies: 4
    Last Post: 05-15-2011, 02:11 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