D
Debra Farnham
Hi All
Access 2000
I've been trying to create a query that will show me the names of all
employees who have completed ALL training topics required by their job
titles.
Background:
I have a table called tblSessions that holds all details with respect to a
training session (fields of interest for the query would be autSessionID and
lngTopicID). There are other fields in the table such as date of training,
time training took place, instructor and length of training.
I have another table called tblTrainingDetails that only contains two
fiields - lngSessionID and lngEmployeeID - both fields used as multiple
primary key to ensure no employee can be added to the same training session
more than once.
I have a third table called tblRequirementsbyPosition that contains only two
fields as well - lngJobTitleID and lngTopicID and a table named
tblEmployees contains the lngJobTitleID field for each employee.
Unfortunately, I cannot see the forest for the trees on this one. I have
created a query that will give me a list of all the requried topics
(actually the lngTopicID) for a specific job titled based on the selectiion
of a job title in a combobox on a form.
SQL:
SELECT tblRequirementsByPosition.lngTopicID
FROM tblRequirementsByPosition
WHERE
(((tblRequirementsByPosition.lngJobTitleID)=[forms]![frmwhosdonewhat]![cboJo
bTitle]));
This will usually return anywhere between 1 and 15 lngTopicID's.
I want to take the results of that query and find all employees who have
completed ALL of those training topics.
It was suggested in another newsgroup that I use a double "frustrated" outer
join and I was provided with the following:
SELECT Main.EmployeeID
FROM tblEmployees AS Main
LEFT JOIN
(
SELECT EmpRequiredTraining.EmployeeID
FROM
(
SELECT E.EmployeeID, RT.[frg_TopicID]
FROM tblEmployees AS E INNER JOIN tblRequiredTraining AS RT
ON E.[frg_JobTitleID] = RT.[JobTitleID]
)
AS EmpRequiredTraining
LEFT JOIN
(
SELECT TD.[frg_EmployeeID], S.[frg_TopicID]
FROM tblTrainingDetails AS TD INNER JOIN tblSessions AS S
ON TD.[frg_SessionID] = S.[SessionID]
)
AS EmpCompletedTraining
ON (EmpRequiredTraining.EmployeeID =
EmpCompletedTraining.[frg_EmployeeID])
AND (EmpRequiredTraining.[frg_TopicID] =
EmpCompletedTraining.[frg_TopicID])
WHERE (EmpCompletedTraining.[frg_EmployeeID] Is Null)
)
AS EmpToBeTrained
ON Main.EmployeeID = EmpToBeTrained.EmployeeID
WHERE (EmpToBeTrained.EmployeeID Is Null)
Unfortunately, I have been unable to implement it and the thread where I
requested additional assistance has gone "cold".
I would be extremely appreciative to anyone with enough patience willing to
help me thru this forest
Debra
Access 2000
I've been trying to create a query that will show me the names of all
employees who have completed ALL training topics required by their job
titles.
Background:
I have a table called tblSessions that holds all details with respect to a
training session (fields of interest for the query would be autSessionID and
lngTopicID). There are other fields in the table such as date of training,
time training took place, instructor and length of training.
I have another table called tblTrainingDetails that only contains two
fiields - lngSessionID and lngEmployeeID - both fields used as multiple
primary key to ensure no employee can be added to the same training session
more than once.
I have a third table called tblRequirementsbyPosition that contains only two
fields as well - lngJobTitleID and lngTopicID and a table named
tblEmployees contains the lngJobTitleID field for each employee.
Unfortunately, I cannot see the forest for the trees on this one. I have
created a query that will give me a list of all the requried topics
(actually the lngTopicID) for a specific job titled based on the selectiion
of a job title in a combobox on a form.
SQL:
SELECT tblRequirementsByPosition.lngTopicID
FROM tblRequirementsByPosition
WHERE
(((tblRequirementsByPosition.lngJobTitleID)=[forms]![frmwhosdonewhat]![cboJo
bTitle]));
This will usually return anywhere between 1 and 15 lngTopicID's.
I want to take the results of that query and find all employees who have
completed ALL of those training topics.
It was suggested in another newsgroup that I use a double "frustrated" outer
join and I was provided with the following:
SELECT Main.EmployeeID
FROM tblEmployees AS Main
LEFT JOIN
(
SELECT EmpRequiredTraining.EmployeeID
FROM
(
SELECT E.EmployeeID, RT.[frg_TopicID]
FROM tblEmployees AS E INNER JOIN tblRequiredTraining AS RT
ON E.[frg_JobTitleID] = RT.[JobTitleID]
)
AS EmpRequiredTraining
LEFT JOIN
(
SELECT TD.[frg_EmployeeID], S.[frg_TopicID]
FROM tblTrainingDetails AS TD INNER JOIN tblSessions AS S
ON TD.[frg_SessionID] = S.[SessionID]
)
AS EmpCompletedTraining
ON (EmpRequiredTraining.EmployeeID =
EmpCompletedTraining.[frg_EmployeeID])
AND (EmpRequiredTraining.[frg_TopicID] =
EmpCompletedTraining.[frg_TopicID])
WHERE (EmpCompletedTraining.[frg_EmployeeID] Is Null)
)
AS EmpToBeTrained
ON Main.EmployeeID = EmpToBeTrained.EmployeeID
WHERE (EmpToBeTrained.EmployeeID Is Null)
Unfortunately, I have been unable to implement it and the thread where I
requested additional assistance has gone "cold".
I would be extremely appreciative to anyone with enough patience willing to
help me thru this forest
Debra