A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Report



 
 
Thread Tools Display Modes
  #1  
Old January 9th, 2010, 08:53 AM posted to microsoft.public.access.tablesdbdesign
new2access via AccessMonster.com
external usenet poster
 
Posts: 13
Default Report

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/For...esign/201001/1

  #2  
Old January 9th, 2010, 06:17 PM posted to microsoft.public.access.tablesdbdesign
theDBguy[_2_]
external usenet poster
 
Posts: 29
Default Report

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/For...esign/201001/1

.

  #3  
Old January 11th, 2010, 05:13 PM posted to microsoft.public.access.tablesdbdesign
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Report

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/For...esign/201001/1

.

  #4  
Old January 11th, 2010, 07:23 PM posted to microsoft.public.access.tablesdbdesign
Dorian
external usenet poster
 
Posts: 542
Default Report

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/For...esign/201001/1

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.