Results 1 to 2 of 2
  1. #1
    CEV is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2011
    Posts
    7

    Help with complex Query

    So I created this query in design view, as with any other query I have created. I have a form with a list of trainings and a check box next to each that will be checked once the person has completed that training. I ultimately want to create a report that only lists people that are currently here along with only listing what trainings they have not completed. I have the SQL view shown below to show what I have so far for the query. It is of course not showing what I want which is why I am here.



    For one, the (((tblEmployees.DateLeftAgency) Is Null) part is not working. It is showing people that have left. And I thought ((tblEmployeePositions.DateStarted)=(SELECT Max(Temp.DateStarted) FROM tblEmployeePositions as Temp WHERE Temp.EmployeeNumber = tblEmployeePositions.EmployeeNumber)) would only show the last position they were in but some people are in the results more than once as they have held more than one position.

    Finally, for each person it is showing all the training whether they have completed it or not. That is understandable, so will this need to be handled in the Report?

    Thanks,
    Chad

    SELECT tblEmployees.LastName, tblEmployees.FirstName, tblPositions.Department, tblEmployees.DateLeftAgency, tblTraining.OrienCompleted, tblTraining.RightsCompleted, tblTraining.FireCompleted, tblTraining.UnivPrecCompleted, tblTraining.SwallSafCompleted, tblTraining.CPRCompleted, tblTraining.PosSupCompleted, tblTraining.ManRepCompleted, tblTraining.[1TBCompleted], tblTraining.[2TBCompleted], tblTraining.DeptCheckCompleted, tblTraining.JobDesCompleted, tblTraining.EmergProCompleted, tblTraining.PersCareCompleted, tblTraining.[P&PCompleted], tblTraining.[1stAidCompleted], tblTraining.DietProcCompleted, tblTraining.ShadowCompleted, tblTraining.PersSpecCompleted, tblTraining.SupObsCompleted, tblTraining.MedAdminCompleted, tblTraining.CDS30Completed, tblTraining.CDS90Completed, tblTraining.SafeTransCompleted
    FROM ((tblDepartments INNER JOIN tblPositions ON (tblDepartments.DeptName = tblPositions.Department) AND (tblDepartments.DeptName = tblPositions.Department)) INNER JOIN (tblEmployees INNER JOIN tblEmployeePositions ON tblEmployees.EmployeeNumber = tblEmployeePositions.EmployeeNumber) ON tblPositions.PositionNumber = tblEmployeePositions.PositionNumber) INNER JOIN tblTraining ON (tblEmployees.EmployeeNumber = tblTraining.EmployeeNumber) AND (tblEmployeePositions.EmployeeNumber = tblTraining.EmployeeNumber)
    WHERE (((tblEmployees.DateLeftAgency) Is Null) AND ((tblEmployeePositions.DateStarted)=(SELECT Max(Temp.DateStarted) FROM tblEmployeePositions as Temp WHERE Temp.EmployeeNumber = tblEmployeePositions.EmployeeNumber)) AND ((tblTraining.OrienCompleted)=No) or ((tblTraining.CPRCompleted)=No) or ((tblTraining.PosSupCompleted)=No) or ((tblTraining.ManRepCompleted)=No) or ((tblTraining.[1TBCompleted])=No) or ((tblTraining.[2TBCompleted])=No) or ((tblTraining.DeptCheckCompleted)=No) or ((tblTraining.JobDesCompleted)=No) or ((tblTraining.EmergProCompleted)=No) or ((tblTraining.PersCareCompleted)=No) or ((tblTraining.[P&PCompleted])=No) or ((tblTraining.[1stAidCompleted])=No) or ((tblTraining.DietProcCompleted)=No) or ((tblTraining.ShadowCompleted)=No) or ((tblTraining.PersSpecCompleted)=No) or ((tblTraining.SupObsCompleted)=No) or ((tblTraining.MedAdminCompleted)=No) or ((tblTraining.CDS30Completed)=No) or ((tblTraining.CDS90Completed)=No) or ((tblTraining.SafeTransCompleted)=No)) OR (((tblTraining.RightsCompleted)=No)) OR (((tblTraining.FireCompleted)=No)) OR (((tblTraining.UnivPrecCompleted)=No)) OR (((tblTraining.SwallSafCompleted)=No))
    ORDER BY tblPositions.Department;
    Last edited by CEV; 03-10-2011 at 03:26 PM. Reason: solved

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you mark this Solved in error? If not, would you like to share your solution with others that read this forum?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query too complex error
    By kaledev in forum Queries
    Replies: 9
    Last Post: 02-14-2011, 02:23 PM
  2. Help with complex query (for me at least)
    By GrindEspresso in forum Queries
    Replies: 5
    Last Post: 01-26-2011, 11:03 AM
  3. Complex query system for map database
    By brian.tunks in forum Queries
    Replies: 2
    Last Post: 07-28-2010, 07:07 AM
  4. Complex Query/Queries for a Report
    By Rawb in forum Queries
    Replies: 3
    Last Post: 02-04-2010, 07:44 AM
  5. Complex Update query
    By niihla10 in forum Queries
    Replies: 1
    Last Post: 08-28-2009, 01:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums