I have a database in which I calculate overtime hours earned and refused. I have tblhours which adds all the hours up which were worked refering to an overtime code. The same column in tblhours when refering to a different overtime code, ie: "2, 5, or 7" adds up all the overtime hours refused. Everything works great, but once a year per our union contract I need to roll back overtime taking the lowest employees total (hours worked + hours refused) and subtract them from each and everyone's overtime. The problem I am having is the structure of my table I have all the hours reported in one column and I query on different overtime codes sorting out the data I need. Say....an employees hours worked are 22.2, hours refused are 2.2 and ytd hours are 24.4 and is indeed the lowest number of hours, so I need to subtract his hours from each employee, when I do an append query and subtract 24.4 hours from him, the results I get are -2.2 hours worked, 2.2 refused hours, and 0 ytd. The ytd date is 0 and that is what I want, but how do I subtract those hours and and get 0 worked, 0 refused, and 0 ytd? I will post an append query that someone else was helping me with, but it doesn't quite work. Do I have the structure of my table set up wrong or possibly should I be storing a running total somewhere? Any help would be greatly appreciated.
INSERT INTO tblhours ( EmployeeName, TMSEmployeeNo, DateWorked, OvertimeCodes, HoursWorked )
SELECT tblHours.EmployeeName, tblHours.TMSEmployeeNo, Date() AS X, "Rollback" AS Y, -[Enter the number of hours to rollback] AS Z
FROM tblEmployees INNER JOIN tblHours ON tblEmployees.Tmsemployeeno = tblHours.TMSEmployeeNo
GROUP BY tblHours.EmployeeName, tblHours.TMSEmployeeNo, "Rollback", -[Enter the number of hours to rollback], tblEmployees.ClassNo, tblEmployees.OutPost
HAVING (((tblEmployees.ClassNo)="52133") AND ((tblEmployees.OutPost)>-1));
Thanks,
Melinda
INSERT INTO tblhours ( EmployeeName, TMSEmployeeNo, DateWorked, OvertimeCodes, HoursWorked )
SELECT tblHours.EmployeeName, tblHours.TMSEmployeeNo, Date() AS X, "Rollback" AS Y, -[Enter the number of hours to rollback] AS Z
FROM tblEmployees INNER JOIN tblHours ON tblEmployees.Tmsemployeeno = tblHours.TMSEmployeeNo
GROUP BY tblHours.EmployeeName, tblHours.TMSEmployeeNo, "Rollback", -[Enter the number of hours to rollback], tblEmployees.ClassNo, tblEmployees.OutPost
HAVING (((tblEmployees.ClassNo)="52133") AND ((tblEmployees.OutPost)>-1));
Thanks,
Melinda