Results 1 to 5 of 5
  1. #1
    nanderson is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    6

    Running a query based on a Combo Box and a List Box

    I wasn't sure where to post this in the forum as it crosses over a few different areas, so if thi is not the right area, let me know and I can repost it.



    I want to be able to do the following, I have a form that has a combo box that lists various locations. I have a list box that list various criteria. I want to be able to have the end user select their location and then choose an option from the list box and hit the run query button and it will run that query.

    Is this possible? I have included a picture of the form below that I have in mind.


    Click image for larger version. 

Name:	2020-05-05_12-05-50.jpg 
Views:	21 
Size:	17.5 KB 
ID:	41755

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    If the list box is not in multiple selection mode then simply reference both of them in the query:

    SELECT tblYourTable.* FROM tblYourTable WHERE [Location] = [Forms]![frmYourForm]![cboLocation] AND [Criteria] = [Forms]![frmYourForm]![lstCriteria];

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    nanderson is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    6
    Thanks for that information Gicu. I will give that a try and report back if there are any issues.

    Have a great day!

  4. #4
    nanderson is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    6
    Ok, so I want to change this query up a bit. I want to use combo boxes to achieve my results. Here is what I am wanting to do, and I don't know if the process would be any different or not.

    I have a form with two drop downs, one for school, and one for various queries they can run. Those queries are setup as statements, like Active Assets by Employee, Recycled Assets, etc. What I am looking wanting this form to do is for the end user to select their school, that populates in various queries that I have built, and then from there link those queries to the various items in the combo box. For example, if someone selects school 1 and active assets by employee, it would pull the query, active assets by employee and use that selection. I don't know if this is possible or not.

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    The listbox can be connected to the combo with this method:

    http://www.baldyweb.com/CascadingCombo.htm

    As far as this goes, there's really no difference between a combo and a listbox for the second control. It would be unusual to open a query for the users. Most of us only let users see forms and reports, never tables or queries. You have little control over what the user can do in them. To that end, if your listbox had a hidden column with actual form or report names, you could easily open the relevant object. If you want to allow multiple selections, it gets a little more involved but not difficult. I take it there are no other criteria, like a date range?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 10
    Last Post: 08-19-2018, 01:22 PM
  2. Replies: 2
    Last Post: 07-28-2016, 04:56 PM
  3. Replies: 4
    Last Post: 10-21-2013, 11:06 AM
  4. Replies: 13
    Last Post: 08-08-2013, 04:52 PM
  5. Running a query based on 2 combo boxes.
    By blessoni in forum Queries
    Replies: 4
    Last Post: 12-12-2010, 02:09 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