troubleshooting Question

Multiple 'OR' operator criteria for query

Avatar of databarracks
databarracks asked on
15 Comments1 Solution266 ViewsLast Modified:
Hi there,

I would like to know what I am doing wrong with a particluar query that I am trying to filter multiple results based on  form fields.

I have a table with 4 boolean fields and would like for my query to return the results only where the relevant form check boxes are true. If the criteria for that field is false I don't want it to return if corresponding check box on the form hasn't been ticked. For example if I tick txtBox1 and txtBox 2 on my form I only want to show records where Service 1 OR Service2 are true and so on. Please see code below:

SELECT tblCompany.company_id, tblCompany.company_name, tblCompany.cancelled, tblCompany.Service1, tblCompany. Service2, tblCompany. Service3, tblCompany. Service4
FROM tblCompany
WHERE (((tblCompany.company_id) Not Like 632 And (tblCompany.company_id) Not Like 633) AND ((tblCompany.cancelled)=False) AND ((tblCompany. service1)=[Forms]![frmOtherServices]![txtBox1])) OR (((tblCompany.service2)=[Forms]![frmOtherServices]![txtBox2])) OR (((tblCompany.service3)=[Forms]![frmOtherServices]![txtBox3])) OR (((tblCompany.service4)=[Forms]![frmOtherServices]![txtBox4]))
ORDER BY tblCompany.company_name;

Many thanks for your help in advance
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros