Report

  • Thread starter new2access via AccessMonster.com
  • Start date
N

new2access via AccessMonster.com

I have this code on my database that show certain records based on a training
modules completed selected by the user from a drop down list.

SELECT [Training Sessions].ModuleName, [Training Sessions].SessionDate,
[Training Sessions].SessionTimeFrom, [Training Sessions].SessionTimeTo,
[Training Sessions].SessionVenue, [Training Records].TraineeID, (forms!
[frmTraining Modules Completed by Trainees]!SelectModule) AS Expr1, [Training
Records].NoShow
FROM [Training Sessions] INNER JOIN [Training Records] ON [Training Sessions].
TSID = [Training Records].TSID
WHERE ((([Training Sessions].ModuleName)=([forms]![frmTraining Modules
Completed by Trainees]![SelectModule]))) OR (((([forms]![frmTraining Modules
Completed by Trainees]![SelectModule])) Is Null));


How can i do it in reverse? i tried this code:

SELECT qryTrainingModules.ModuleName, qryTrainingModules.SessionDate,
qryTrainingModules.TraineeID, Trainees.LastName, Trainees.FirstName, Trainees.
JobTitle, Trainees.ContractorName, qryTrainingModules.NoShow, Trainees.
Language
FROM Trainees INNER JOIN qryTrainingModules ON Trainees.TraineeID =
qryTrainingModules.TraineeID
WHERE (((qryTrainingModules.NoShow)<>False));

This shows a report of trainees who failed to attend the training course,
which is also needed on the report since they have to take the course again.
Also, i need to display on this report the trainees who doesn't have training
history so they can be enrolled. And that's my problem, its not showing
trainees with no training history.



My database has the following tables:

[Trainees]
- TraineeID (PK)
- FirstName
- LastName
- etc...

[Training Records]
- ID (PK)
- TraineeID
- TSID
- NoShow

[Training Sessions]
- TSID (PK)
- ModuleName
- SessionDate
- SessionTime

[tblModules]
- ModuleName (PK)
 
T

theDBguy

Hi,

Let's try something like:

SELECT TraineeID, FirstName, LastName
FROM Trainees
LEFT JOIN [Training Records]
ON Trainees.TraineeID=[Training Records].TraineeID
WHERE [Training Records].TraineeID Is Null

(untested)
Hope that helps...
 
D

Daryl S

You need an outer join to get the trainees without training history, and you
must alter the WHERE clause to account for records that have no training
history:

SELECT qryTrainingModules.ModuleName, qryTrainingModules.SessionDate,
qryTrainingModules.TraineeID, Trainees.LastName, Trainees.FirstName, Trainees.
JobTitle, Trainees.ContractorName, qryTrainingModules.NoShow, Trainees.
Language
FROM Trainees LEFT JOIN qryTrainingModules ON Trainees.TraineeID =
qryTrainingModules.TraineeID
WHERE (((qryTrainingModules.NoShow)<>False) or (qryTrainingModules.NoShow)
is null));
 
D

Dorian

I think you need to do a LEFT join. An INNER JOIN only returns records where
the record exists in both tables (which does not work because there are no
training records). A LEFT join will return the matching records and the
records that have no match.
Read up on LEFT joins in Access HELP system.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Yes/No 7
count record 6
Count YES/NO Field 2
count record on subform 0
relationship - query 2
Active/Inactive - REPORTING 1
Display highest rate of record 4
query / combo box 14

Top