Hi,
I am designing a query which will return results based on user selections in a form.
The user can choose from Company, Service, Number of Issues, and Category, choosing from as many or as few of these options as they wish to search by. The user also enters a number which is the greatest price they wish to see.
The results are also filtered by dates after today's date automatically.
The query runs upon the click of a button in the search form.
The SQL of the query is here:
SELECT tblCompanies.Company, tblServicePrice.Service, tblServicePrice.[Number of Issues], tblCompanies.Category, tblServicePrice.[Price in £], tblDeadlines.Deadline, tblDeadlines.Issue, tblServicePrice.[Original Price]
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 ((tblServicePrice.[Number of Issues])=[Forms]![SearchF]![Number of Issues]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND ((tblCompanies.Category.Value)=[Forms]![SearchF]![Category])) OR (((tblServicePrice.[Number of Issues])=[Forms]![SearchF]![Number of Issues]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND ((tblCompanies.Category.Value)=[Forms]![SearchF]![Category]) AND (([Forms]![SearchF]![Service]) Is Null)) OR (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND ((tblCompanies.Category.Value)=[Forms]![SearchF]![Category]) AND (([Forms]![SearchF]![Number of Issues]) Is Null)) OR (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblServicePrice.[Number of Issues])=[Forms]![SearchF]![Number of Issues]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblCompanies.Category.Value)=[Forms]![SearchF]![Category]) AND (([Forms]![SearchF]![Company]) Is Null)) OR (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblServicePrice.[Number of Issues])=[Forms]![SearchF]![Number of Issues]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND (([Forms]![SearchF]![Category]) Is Null)) OR (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblServicePrice.[Number of Issues])=[Forms]![SearchF]![Number of Issues]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND (([Forms]![SearchF]![Company]) Is Null) AND (([Forms]![SearchF]![Category]) Is Null)) OR (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND (([Forms]![SearchF]![Number of Issues]) Is Null) AND (([Forms]![SearchF]![Company]) Is Null) AND (([Forms]![SearchF]![Category]) Is Null)) OR (((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblCompanies.Category.Value)=[Forms]![SearchF]![Category]) AND (([Forms]![SearchF]![Service]) Is Null) AND (([Forms]![SearchF]![Number of Issues]) Is Null) AND (([Forms]![SearchF]![Company]) Is Null)) OR (((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND ((tblCompanies.Category.Value)=[Forms]![SearchF]![Category]) AND (([Forms]![SearchF]![Service]) Is Null) AND (([Forms]![SearchF]![Number of Issues]) Is Null)) OR (((tblServicePrice.[Number of Issues])=[Forms]![SearchF]![Number of Issues]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblCompanies.Category.Value)=[Forms]![SearchF]![Category]) AND (([Forms]![SearchF]![Service]) Is Null) AND (([Forms]![SearchF]![Company]) Is Null)) OR (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND (([Forms]![SearchF]![Number of Issues]) Is Null) AND (([Forms]![SearchF]![Category]) Is Null)) OR (((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND (([Forms]![SearchF]![Service]) Is Null) AND (([Forms]![SearchF]![Number of Issues]) Is Null) AND (([Forms]![SearchF]![Company]) Is Null) AND (([Forms]![SearchF]![Category]) Is Null)) OR (((tblServicePrice.[Number of Issues])=[Forms]![SearchF]![Number of Issues]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND (([Forms]![SearchF]![Service]) Is Null) AND (([Forms]![SearchF]![Category]) Is Null)) OR (((tblServicePrice.Service)=[Forms]![SearchF]![Service]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblCompanies.Category.Value)=[Forms]![SearchF]![Category]) AND (([Forms]![SearchF]![Number of Issues]) Is Null) AND (([Forms]![SearchF]![Company]) Is Null)) OR (((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND ((tblServicePrice.Company)=[Forms]![SearchF]![Company]) AND (([Forms]![SearchF]![Service]) Is Null) AND (([Forms]![SearchF]![Number of Issues]) Is Null) AND (([Forms]![SearchF]![Category]) Is Null)) OR (((tblServicePrice.[Number of Issues])=[Forms]![SearchF]![Number of Issues]) AND ((tblServicePrice.[Price in £])<=[Forms]![SearchF]![Price in £]) AND ((tblDeadlines.Deadline)>Date()) AND (([Forms]![SearchF]![Service]) Is Null) AND (([Forms]![SearchF]![Company]) Is Null) AND (([Forms]![SearchF]![Category]) Is Null));
I am not sure why I am receiving the error. It happened since I started to also make it possible to search by 'Category'. Does introducing a fourth searchable variable into the form make the query too complex to run?
Thanks!