I have a table with company names and then 10 yes/no boxes that represent what type of company they are (graduate, non-graduate, misc, co-oop, etc...) Every company has at least one box "checked" yes, some have 2 or more.
The problem that i am running into is that I am trying to design a form that will allow a user to select one or many of these categoryies and output the results to a report. It works for companies that only have one box checked, but not for more than one. Any help would be most appreciated. Sample code below:
SELECT DISTINCT Company.Organization, Contacts.[First Name], Contacts.[Last Name], Contacts.Position1, Contacts.Phone, Company.Address1, Company.Address2, Company.City, Company.State, Company.ZipCode, Contacts.[Email Address]
FROM Company INNER JOIN Contacts ON Company.Organization = Contacts.Organization
WHERE (
(Contacts.[Phone]) is not null AND
(
(
((Company.[Health])=[Forms]![Form Master]![HHG]) OR
((Company.[Health Grad])=[Forms]![Form Master]![HHG])
) AND
(
((Company.[Other])=[Forms]![Form Master]![OOG]) OR
((Company.[Other Grad])=[Forms]![Form Master]![OOG])
) AND
((Company.[Edu])=[Forms]![Form Master]![EDU]) AND
((Company.[Co-op])=[Forms]![Form Master]![COOP]) AND
((Company.[Outreach - Other])=[Forms]![Form Master]![OutOther]) AND
((Company.[Outreach - Health])=[Forms]![Form Master]![OutHealth]) AND
((Company.[Outreach - Grad])=[Forms]![Form Master]![OutGrad])
)
)
ORDER BY Company.Organization;
The problem that i am running into is that I am trying to design a form that will allow a user to select one or many of these categoryies and output the results to a report. It works for companies that only have one box checked, but not for more than one. Any help would be most appreciated. Sample code below:
SELECT DISTINCT Company.Organization, Contacts.[First Name], Contacts.[Last Name], Contacts.Position1, Contacts.Phone, Company.Address1, Company.Address2, Company.City, Company.State, Company.ZipCode, Contacts.[Email Address]
FROM Company INNER JOIN Contacts ON Company.Organization = Contacts.Organization
WHERE (
(Contacts.[Phone]) is not null AND
(
(
((Company.[Health])=[Forms]![Form Master]![HHG]) OR
((Company.[Health Grad])=[Forms]![Form Master]![HHG])
) AND
(
((Company.[Other])=[Forms]![Form Master]![OOG]) OR
((Company.[Other Grad])=[Forms]![Form Master]![OOG])
) AND
((Company.[Edu])=[Forms]![Form Master]![EDU]) AND
((Company.[Co-op])=[Forms]![Form Master]![COOP]) AND
((Company.[Outreach - Other])=[Forms]![Form Master]![OutOther]) AND
((Company.[Outreach - Health])=[Forms]![Form Master]![OutHealth]) AND
((Company.[Outreach - Grad])=[Forms]![Form Master]![OutGrad])
)
)
ORDER BY Company.Organization;