I'm working in MS Access trying to iron out an SQL statement that works. On a form I have a combobox that displays a list of employees. I have a separate dialog form that allows the user to select multiple items in a listbox. Each item represents a certification. Each employee can have any number and combination of certifications. Ultimately I just want to update the RowSource property of the combobox to reflect the new filtered data by assigning a proper SQL statement.
If I want to filter the list on the combobox of employees, I use this SQL statement:
SELECT
Employees.Employee_ID, Employees.Last_Name, Employees.First_Name
FROM
Employees
INNER JOIN
Emp_Certs ON Employees.Employee_ID = Emp_Certs.Employee_ID
WHERE
(((Employees.Active_Member) = Yes)
AND ((Emp_Certs.Employee_ID) = [Employees].[Employee_ID])
AND ((Emp_Certs.Cert_ID) = 1))
ORDER BY
Employees.Last_Name;
If I run this query it works because I'm assigning only one value to Emp_Certs.Cert_ID. But when I add another like this:
SELECT
Employees.Employee_ID, Employees.Last_Name, Employees.First_Name
FROM
Employees
INNER JOIN
Emp_Certs ON Employees.Employee_ID = Emp_Certs.Employee_ID
WHERE
(((Employees.Active_Member) = Yes)
AND ((Emp_Certs.Employee_ID) = [Employees].[Employee_ID])
AND ((Emp_Certs.Cert_ID) = 1)
AND ((Emp_Certs.Cert_ID) = 4))
ORDER BY Employees.Last_Name;
I get an empty set. That's not what I expected. The table Emp_Certs clearly has several employees that have the combination of certifications 1 and 4. Could someone please explain how this is supposed to be written if I want to indicate more that one Cert_ID and have the employee record show up only once in the combobox. I don't need the employee records showing up multiple times in the combobox.
This might help:
