From: new2access via AccessMonster.com on
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)

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/201001/1

From: theDBguy on
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...


"new2access via AccessMonster.com" wrote:

> 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)
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/201001/1
>
> .
>
From: Daryl S on
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));


--
Daryl S


"new2access via AccessMonster.com" wrote:

> 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)
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/201001/1
>
> .
>
From: Dorian on
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".


"new2access via AccessMonster.com" wrote:

> 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)
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-tablesdbdesign/201001/1
>
> .
>
 | 
Pages: 1
Prev: setvalue macro
Next: Can't change data type