I am not quite sure how to begin to solve this issue so I will give a bit of an explanation.
I have a query that includes fields from T_employee and fields from T_courses, which is courses taught by each employee per semester and T_Additional, which is additional hours added to employees for each semester.
The query groups by employee and has a calculation of the teachers total hours per course based on teaching hours and factors for marking and preparation and adds the additional hours from T_additional.
Each teacher cannot have more than 44 hours, so there are additional calculations that calculate the consequence of subtracting one course from the total hours. The record that is closest to 44 without going over is optimal. In some cases, subtracting one course is not enough to get the hours below 44 and an additional course will need to be subtracted and perhaps a 3rd an so on.
I would like to evaluate which course is the most optimal to subtract and if it is not enough, then to loop through and subtract the next course until the hours are below 44, but as close to 44 as possible.
Can anyone give me direction on how I would go about this? Would a Do loop be what I need? And if so, where would I put it? I need to output the total number of hours that were subtracted and the number of courses.
I tried creating a query based on this one, grouping by employee and under the NetHours in the totals row, the max nethours <44. This works but there are still a few records where the nethours is >44. I would like to use a Where in the Totals row and in the Criteria somehow indicate that I want the largest number that is less than 44.
Thank you so much for any suggestions or feedback and please let me know if you need clarification.
Anita
I have a query that includes fields from T_employee and fields from T_courses, which is courses taught by each employee per semester and T_Additional, which is additional hours added to employees for each semester.
The query groups by employee and has a calculation of the teachers total hours per course based on teaching hours and factors for marking and preparation and adds the additional hours from T_additional.
Each teacher cannot have more than 44 hours, so there are additional calculations that calculate the consequence of subtracting one course from the total hours. The record that is closest to 44 without going over is optimal. In some cases, subtracting one course is not enough to get the hours below 44 and an additional course will need to be subtracted and perhaps a 3rd an so on.
I would like to evaluate which course is the most optimal to subtract and if it is not enough, then to loop through and subtract the next course until the hours are below 44, but as close to 44 as possible.
Can anyone give me direction on how I would go about this? Would a Do loop be what I need? And if so, where would I put it? I need to output the total number of hours that were subtracted and the number of courses.
I tried creating a query based on this one, grouping by employee and under the NetHours in the totals row, the max nethours <44. This works but there are still a few records where the nethours is >44. I would like to use a Where in the Totals row and in the Criteria somehow indicate that I want the largest number that is less than 44.
Thank you so much for any suggestions or feedback and please let me know if you need clarification.
Anita