I am stuck on this and would love some help. I have a customer who has 3 rates of pay and personnel can in theory go across all three. Working out the rates 1 & 2 are simple as they are in the same day but the 3rd rate goes across midnight. Rate 2 starts at 18:00 and runs till 00:00(24:00). The code below works until we cross this time and then it fails. When I ask the question: is the end time later than rate 3 start time (which means I need to move some hours into the 3rd rate) it gives the wrong answer.
Any help appreciated and gratefully received.
Any help appreciated and gratefully received.
Code:
If CDBreak!CDPTMF2 = True Then 'section 1 'here get the rate time start and rate 2 start for the end time RateTimeStart = CDBreak!CDPTTime2 RateTimeEnd = CDBreak!CDPTTime3 If ThisTimeIn >= RateTimeStart Then 'And ThisTimeIn <= RateTimeEnd Then ' WE HAVE THE RIGHT START RATE 'section 2 'we have the corect rate slot If ThisTimeOut > RateTimeEnd Then 'check to see if we need to go into another time slot ' we now need to split the worked hours into the rate 1 and rate 2 Bookings.Edit 'need to find how many hours in rate 2 and then minus it from the total hours Bookings!BRate1Hrs = Left(RateTimeEnd, 2) - Left(Bookings!BTimeIn, 2) Bookings!BRate2Hrs = Bookings!BHours - Bookings!BRate1Hrs Bookings.Update MsgBox "Rate 1 - " & Bookings!BRate1Hrs & " Hrs & Rate 2 - " & Bookings!BRate2Hrs & " Hrs" Else 'put all hours in the Rate 1 box Bookings.Edit Bookings!BRate1Hrs = Bookings!BHours MsgBox "Rate 1 - " & Bookings!BRate1Hrs & " Hrs" Bookings.Update End If AllSorted = True End If End If
Comment