Jim said:
I would be grateful of some help,
3 Tables ..
tblPersonnel
PayrollID - number(primary key)
Name - text
tblTrainingCourse
CourseCode - Autonumber(primary key)
CourseTitle - text
tblTrainingEmployee
ID - Autonumber(primary key)
PayrollID - Number
CourseCode - Number
So basically how can I list all the payrollID's in
tblPersonnel that have not had a course I choose from
tblTrainingCourse!CourseCode by looking at
tblTrainingEmployee
Hi Jim,
Let's start with a query for a specific CourseCode
(say "6").
Start a new query in Design View and
add tblPersonnel and tblTrainingEmployee.
Right-mouse click on tblPersonnel,
choose "Properties," and change its
Alias to p
Likewise, change alias of tblTrainingEmployee
to t
Drag and drop PayrollID from p
onto PayrollID in t to create inner
join between tables (if no join line already
exists between them).
From p, drag and drop fields
PayrollID
Name
{"Name" is reserved word and good idea to change}
down into field row of separate columns of the bottom grid.
Change your query to groupby query by
clicking on "sigma" icon in top menu.
A new row in the grid will be added
that now says "Group By" under each
column.
In a new column in the field row type in
MIN([CourseCode]=6)
then in its groupby row, choose "Expression"
and in its Criteria row, type 0
Save your query.
Replace "6" with a valid CourseCode.
Save and run.
Does it show the personnel who have
not taken that course?
Change to SQL View,
copy the sql to clipboard
then paste in a reply to this post
if it does not, or you want further
help.
I would imagine a form with a combo box
bound to tblTrainingCourse. The user would
select a CourseTitle, then click on a command
button that constructs the same sql but with the
CourseCode selected in combo box.
This new sql could be applied to RecordSource
of a new form or report you would then open.
Or...
You could make it a parameter query
simply by changing
MIN([CourseCode]=6)
to
MIN([CourseCode]=[Enter Course Code])
///////////////////////////////////////////
Test with Example Data (changed "Name"):
tblPersonnel
PayrollID EmpName
1 Homer
2 Marge
3 Bart
4 Lisa
tblTrainingCourse
CourseCode CourseTitle
1 A
2 B
3 C
4 D
5 E
6 F
tblTrainingEmployee
ID PayrollID CourseCode
1 1 1
2 1 2
3 1 3
4 1 4
5 1 5
6 1 6
7 2 1
8 2 2
9 2 3
10 2 4
11 2 5
12 3 1
13 4 2
Homer(1) took all courses
Marge(2) took all but course 6
Bart(3) took only course 1
Lisa(4) took only course 2
So if run following query
(typing in 6 for parameter)
SELECT
tblPersonnel.PayrollID,
tblPersonnel.EmpName
FROM tblPersonnel INNER JOIN tblTrainingEmployee
ON tblPersonnel.PayrollID = tblTrainingEmployee.PayrollID
GROUP BY tblPersonnel.PayrollID, tblPersonnel.EmpName
HAVING
(((Min([CourseCode]=[Enter Course Code]))=0));
get:
PayrollID EmpName
2 Marge
3 Bart
4 Lisa
Good luck,
Gary Walter