Results 1 to 3 of 3
  1. #1
    dwheatley is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    22

    Determine what query to run based on a checkbox

    Hi,

    I have a form which I use to select a company and a service, and then click a button 'Run Query', returning results according to what company or service were selected.

    Currently these results are automatically date-filtered to only show results with publication deadlines in the future. These deadlines are drawn from one table, tblDeadlines, and the Company/Service data drawn from tblServicePrice (see SQL below).

    I want to instead have a checkbox on the form, which will apply this date filter when I click the 'Run Query' button only if it is ticked. How should I go about this?

    Here is the current SQL for my Query:




    SELECT tblCompanies.Company, tblServicePrice.Service, tblServicePrice.Price, tblServicePrice.Currency, tblServicePrice.[Number of Issues], tblServicePrice.Comments, tblDeadlines.Deadline
    FROM (tblCompanies INNER JOIN tblServicePrice ON tblCompanies.ID = tblServicePrice.Company) INNER JOIN tblDeadlines ON tblCompanies.ID = tblDeadlines.Company
    WHERE (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company])) OR (((tblDeadlines.Deadline)>Date()) AND (([Forms]![SearchF]![Service]) Is Null) AND (([Forms]![SearchF]![Company]) Is Null)) OR (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblDeadlines.Deadline)>Date()) AND (([Forms]![SearchF]![Company]) Is Null)) OR (((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND (([Forms]![SearchF]![Service]) Is Null));

    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    Checkboxes constantly have to be programmed (when modified)
    instead what about a combo box?
    the query in the box has the 'caption' and query to run
    [caption],[qry]
    All Clients, qsClientsAll
    Delinquent, qsClientsDelinq
    Current clients, qsClientsCurr


    The user sees the caption, but runs the query when picked.
    bound col = 2
    set col widths = 1;0 (set zero so the user cant see the query)

    then in the combo AFTERUPDATE event, filter or run the query.
    Just add new queries to the table and the combo is self programming, unlike checkboxes.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

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

Similar Threads

  1. Replies: 2
    Last Post: 06-16-2016, 10:42 AM
  2. Query Based on Form Checkbox
    By tylerpickering in forum Queries
    Replies: 4
    Last Post: 11-11-2014, 09:32 AM
  3. Replies: 4
    Last Post: 09-29-2014, 12:24 PM
  4. Replies: 1
    Last Post: 10-18-2013, 03:14 PM
  5. Replies: 4
    Last Post: 07-12-2011, 09:49 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