DB_Queen
New member
- Local time
- Yesterday, 19:14
- Joined
- Sep 20, 2021
- Messages
- 22
Hello experts:
I have a report I'm creating that calculates the overlap between an employee's schedule and their supervisor.
I have the report grouped by supervisor in a group header and the employee info in a detail section. I'm using VBA to calculate the overlap on the FORMAT event of the detail section, in this way:
If SuperStartTime > EmployeeStartTime Then
Monday1StartTIme = Nz((DateDiff "h", EmployeeStartTime,SuperStartTime),0)
Else
Monday1StartTime = Nz((DateDiff "h", SuperStartTime,EmployeeStartTime),0)
End If
I've included the Nz because sometimes employees or supervisors work a 4/10 schedule where one day of the week has no start or end time. The difference found between the times is stored in a variable, for example here "Monday1StartTime" which is set as DOUBLE.
At the end, all the variables are added up, and subtracted from 80 hours, to get the total hours of overlap.
This calculation works great for about 95% of records; the issue is randomly some employees will display a huge negative number like -87564 instead of "80" or "50" or whatever. The weirdest part is that when I amend the query for the report to pull only that particular employee's record, the calculation will work fine; but when I pull all employee records into the report it will not calculate correctly!
Have any of you run up against something like this before? I am not able to find any obvious similarities between the records where this miscalculation is occurring; however universally if I run the query for ONLY THAT EMPLOYEE the math works fine.
Appreciate any guidance you can provide. Thanks
I have a report I'm creating that calculates the overlap between an employee's schedule and their supervisor.
I have the report grouped by supervisor in a group header and the employee info in a detail section. I'm using VBA to calculate the overlap on the FORMAT event of the detail section, in this way:
If SuperStartTime > EmployeeStartTime Then
Monday1StartTIme = Nz((DateDiff "h", EmployeeStartTime,SuperStartTime),0)
Else
Monday1StartTime = Nz((DateDiff "h", SuperStartTime,EmployeeStartTime),0)
End If
I've included the Nz because sometimes employees or supervisors work a 4/10 schedule where one day of the week has no start or end time. The difference found between the times is stored in a variable, for example here "Monday1StartTime" which is set as DOUBLE.
At the end, all the variables are added up, and subtracted from 80 hours, to get the total hours of overlap.
This calculation works great for about 95% of records; the issue is randomly some employees will display a huge negative number like -87564 instead of "80" or "50" or whatever. The weirdest part is that when I amend the query for the report to pull only that particular employee's record, the calculation will work fine; but when I pull all employee records into the report it will not calculate correctly!
Have any of you run up against something like this before? I am not able to find any obvious similarities between the records where this miscalculation is occurring; however universally if I run the query for ONLY THAT EMPLOYEE the math works fine.
Appreciate any guidance you can provide. Thanks
