Results 1 to 7 of 7
  1. #1
    TheHarleygirl2005 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    34

    Generate Report that list current training course only

    I need to generate a training report that only lists the most current training records. In my TrainingT I have the following fields

    EmployeeID
    CourseDate
    CourseType


    CourseName
    ExipirationDate
    TrainingYear

    Many of these courses are annual courses so there will be a new listing in the table for each year, but I need my report to only pull the most recent courses for each employee. Each employee would have several courses per report (i.e, Medical Course, Defensive Driving Course, etc.).

    I'm looking for direction on how to make this happen. Can anyone help?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    One way is with TOP n parameter. Review: http://allenbrowne.com/subquery-01.html#TopN
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    TheHarleygirl2005 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    34
    The TopN did not help. I have a query (MandatoryTrainingQ) that only lists Mandatory Training

    Click image for larger version. 

Name:	MTrainingQ.jpg 
Views:	7 
Size:	61.3 KB 
ID:	13896

    SELECT TrainingT.[MIS#], TrainingT.CourseDate, TrainingT.CourseType, TrainingT.CourseID, CourseNameT.CourseDescription, TrainingT.CourseName, TrainingT.[Certification#], TrainingT.ExpirationDate
    FROM TrainingT INNER JOIN CourseNameT ON TrainingT.CourseID = CourseNameT.CourseID
    WHERE (((CourseNameT.CourseDescription)<>"Other"));


    This query only displays my mandatory training courses for each member. If it is an elective course I select "Other" from my CourseDescription (which is filtered out)Now I need it to only pull the maximum date. I'm thinking using the Max() function might work, but I have never done that before and can't seem to get it right. Any suggestions?
    Attached Thumbnails Attached Thumbnails MandatoryTrainingQ.jpg  

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Why didn't TOP N work, what happened?

    Try this:

    If you want the max date for each member for each course:
    Select MemberID, CourseID, Max(CourseDate) AS MaxCourseDate FROM TrainingT GROUP BY MemberID, CourseID;

    Now join that query to TrainingT by linking on the MemberID and CourseID fields. Use criteria under CourseDate field: =[MaxCourseDate]
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    TheHarleygirl2005 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    34
    I probably just don't know what I'm doing with the TOP N. This is what I have and it does not return any records.

    SELECT TrainingT.[MIS#], TrainingT.CourseDate, TrainingT.CourseType, TrainingT.CourseID, CourseNameT.CourseDescription, TrainingT.CourseName, TrainingT.[Certification#], TrainingT.ExpirationDate
    FROM TrainingT INNER JOIN CourseNameT ON TrainingT.CourseID = CourseNameT.CourseID
    WHERE (((CourseNameT.CourseDescription)<>"Other")) IN
    (SELECT TOP 1 CourseDate
    FROM TrainingT
    WHERE TrainingT.CourseID = CourseNameT.CourseID
    ORDER BY CourseDate DESC, AttendanceID DESC)

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did the other approach work?

    I am not sure because can't test your data but the TOP N should be more like:

    SELECT TrainingT.*, CourseDescription
    FROM TrainingT INNER JOIN CourseNameT ON TrainingT.CourseID = CourseNameT.CourseID
    WHERE CourseNameT.CourseDescription<>"Other" AND AttendanceID IN
    (SELECT TOP 1 AttendanceID FROM TrainingT AS Dupe
    WHERE Dupe.CourseID = TrainingT.CourseID AND
    Dupe.EmployeeID = TrainingT.EmployeeID
    ORDER BY Dupe.CourseDate, DESC);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    TheHarleygirl2005 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    34
    I have tried playing with this code where I have a "MemberID" rather than "EmployeeID" as you it have but I keep getting a Syntax error

    Click image for larger version. 

Name:	Error.jpg 
Views:	5 
Size:	56.2 KB 
ID:	13909

    Here is my updated code:

    SELECT TrainingT.*, CourseDescription
    FROM TrainingT INNER JOIN CourseNameT ON TrainingT.CourseID = CourseNameT.CourseID
    WHERE CourseNameT.CourseDescription<>"Other" AND AttendanceID IN
    (SELECT TOP 1 AttendanceID FROM TrainingT AS Dupe
    WHERE Dupe.CourseID = TrainingT.CourseID AND
    Dupe.MemberID = TrainingT.MemberID
    ORDER BY Dupe.CourseDate, DESC);
    Attached Thumbnails Attached Thumbnails Syntax error.jpg  

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

Similar Threads

  1. Replies: 8
    Last Post: 06-04-2014, 10:41 AM
  2. Replies: 1
    Last Post: 09-24-2012, 07:09 PM
  3. staff training data base, training
    By SAJAN in forum Forms
    Replies: 1
    Last Post: 09-22-2012, 05:09 AM
  4. how to generate this simple report in report ms access
    By learning_graccess in forum Reports
    Replies: 1
    Last Post: 11-26-2011, 02:10 PM
  5. Query Won't Generate Report
    By italianfinancier in forum Queries
    Replies: 1
    Last Post: 06-02-2011, 03:48 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