Access Determine what query to run based on a checkbox


Joined
Nov 28, 2017
Messages
1
Reaction score
0
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!
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top