Results 1 to 6 of 6
  1. #1
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165

    Select Employee/Course combination for each course required for the a Group

    Hello all,



    I am creating a report and I am not quite sure how to go about doing it. Below are my relationships.

    Click image for larger version. 

Name:	relationships.png 
Views:	14 
Size:	11.8 KB 
ID:	28992

    Background

    Each of the employees is assigned to a Group. Each group is assigned a set of courses. So if an employee is an engineer, he/she will take all of the courses that engineers have to take. Any training done is tracked in another table.

    tblEmployees - Contains employee information, including the group to which the employee belongs
    tblCourses - Contains course information
    tblRequiredCoursesforJobGroups - Contains information on which courses each group requires
    tblEmployeeTrainingTracker - Tracks each course completed.

    What I'm trying to do

    I am aiming to create a query/report that will show the training done by employees, as well as the training that has not been completed by each employee based on their job group. So if Joe is an engineer, and engineer's have to take Course1, Course2, and Course4, but has only completed Course1, and Course2, the query will show the following:

    Name -- Job -------- Course --- Date Completed

    Joe ----- Engineer -- Course1 -- 5 Jan 17
    Joe ----- Engineer -- Course2 -- 9 Feb 17
    Joe ----- Engineer -- Course4 -- Incomplete

    Any ideas as to how to do this?

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    It would really help if you called fields by the same name across tables,, giving an instant recognition of the relationship structure. For instance, JobGroup on tblEmployees needs to link directly to JobGroup on tblRequiredCoursesforJobGroups.. This is not readily apparent.

    There is a table missing, the table containing job groups.

    The links for your query would be tblEmployee JobGroupID to tblJobGroups, to tblRequiredCoursesforJobGroups.CourseID. Then employee id plus course id to tracking table.

    Don't worry about the report or what it is going to look like, first get the query with the data correct. The wizard can create the report for you based on that.

  3. #3
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165
    aytee111,

    Thank you for your reply. I'm attempting to get the query wizard to return the proper data; however, I am getting multiple erroneous rows:

    Code:
    SELECT DISTINCT tblEmployees.Name, tblRequiredCoursesforJobGroups.TrainingDescription, tblRequiredCoursesforJobGroups.Course, tblEmployeeTrainingTracker.LastCompleted
    FROM tblRequiredCoursesforJobGroups INNER JOIN (tblEmployeeTrainingTracker INNER JOIN tblEmployees ON tblEmployeeTrainingTracker.[EmployeeID] = tblEmployees.[EmployeeID]) ON tblRequiredCoursesforJobGroups.[TrainingDescription] = tblEmployees.[JobGroup]
    WHERE (((tblRequiredCoursesforJobGroups.Required)=True))
    GROUP BY tblEmployees.Name, tblRequiredCoursesforJobGroups.TrainingDescription, tblRequiredCoursesforJobGroups.Course, tblEmployeeTrainingTracker.LastCompleted;
    I can get the correct Courses based on Job Group pulled up this way:

    Code:
    SELECT DISTINCT tblEmployees.Name, tblRequiredCoursesforJobGroups.TrainingDescription, tblRequiredCoursesforJobGroups.Course, tblRequiredCoursesforJobGroups.Required
    FROM tblRequiredCoursesforJobGroups INNER JOIN (tblEmployeeTrainingTracker INNER JOIN tblEmployees ON tblEmployeeTrainingTracker.[EmployeeID] = tblEmployees.[EmployeeID]) ON tblRequiredCoursesforJobGroups.[TrainingDescription] = tblEmployees.[JobGroup]
    WHERE (((tblRequiredCoursesforJobGroups.Required)=True));
    But if I add the LastCompleted to this, it shows every combination of LastCompleted date and the required courses for the job group. Also, for the ones that aren't completed it doesn't come up blank. This is where I'm stuck.

  4. #4
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165
    Quote Originally Posted by aytee111 View Post
    It would really help if you called fields by the same name across tables,, giving an instant recognition of the relationship structure. For instance, JobGroup on tblEmployees needs to link directly to JobGroup on tblRequiredCoursesforJobGroups.. This is not readily apparent.

    There is a table missing, the table containing job groups.

    The links for your query would be tblEmployee JobGroupID to tblJobGroups, to tblRequiredCoursesforJobGroups.CourseID. Then employee id plus course id to tracking table.

    Don't worry about the report or what it is going to look like, first get the query with the data correct. The wizard can create the report for you based on that.
    If it makes things simpler I'm only looking to pull records for incomplete courses.

  5. #5
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Try not to use the query wizard for select queries, you know what you want.

    Start at the lowest echelon of data: employee ID, job group, required courses
    Add the max date of the required course taken by the employee.
    Add the missing courses (left join required courses to tracker table and find where the tracker course id is null).

    Take as many queries as you want to get here.

    Now you have all the data laid out correctly. Once this is working, add in the "user" fields - names, descriptions, etc.

  6. #6
    AccessPower's Avatar
    AccessPower is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2016
    Posts
    165
    Quote Originally Posted by aytee111 View Post
    Try not to use the query wizard for select queries, you know what you want.

    Start at the lowest echelon of data: employee ID, job group, required courses
    Add the max date of the required course taken by the employee.
    Add the missing courses (left join required courses to tracker table and find where the tracker course id is null).

    Take as many queries as you want to get here.

    Now you have all the data laid out correctly. Once this is working, add in the "user" fields - names, descriptions, etc.
    I think I have it working now! It was the left join that was messing me up. Will report back with the final results.

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

Similar Threads

  1. Replies: 9
    Last Post: 01-31-2017, 05:13 PM
  2. Select latest record for each Employee and Course
    By AccessPower in forum Queries
    Replies: 3
    Last Post: 12-16-2016, 01:09 PM
  3. Replies: 2
    Last Post: 01-27-2016, 08:38 AM
  4. Replies: 6
    Last Post: 06-09-2015, 09:51 AM
  5. GROUP by yet SELECT fields not within GROUP BY
    By johnseito in forum Access
    Replies: 25
    Last Post: 11-03-2013, 10:20 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