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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|