Hi Experts,
I am using the below code to update the "freeat" time but I am not getting the right calculation. Could you assist? Find the screenshot
1) In the first row "freeat" time for emp4 is "01/11/19 3:10" when he picks the second task ( second row ) he will be free at "01/11/19 15:10" since "tasktime" is 12 hrs.
(01/11/19 3:10 + 12:00 gives 01/11/19 15:10)
Till this code is fine but from the third row freeat time is not correct ("01/11/19 14:10" is the result as it still incorrectly takes freeat as (01/11/19 3:10 + 11:00 ) instead of
(01/11/19 15:10 +11:00) and so on
I understand I have done a mistake here "
but how do I assign a variable
I am using the below code to update the "freeat" time but I am not getting the right calculation. Could you assist? Find the screenshot
1) In the first row "freeat" time for emp4 is "01/11/19 3:10" when he picks the second task ( second row ) he will be free at "01/11/19 15:10" since "tasktime" is 12 hrs.
(01/11/19 3:10 + 12:00 gives 01/11/19 15:10)
Till this code is fine but from the third row freeat time is not correct ("01/11/19 14:10" is the result as it still incorrectly takes freeat as (01/11/19 3:10 + 11:00 ) instead of
(01/11/19 15:10 +11:00) and so on
I understand I have done a mistake here "
Code:
arrfree(UBound(arrfree)) = ![freeat]"
Code:
Private Sub upd()
Dim rsTask As DAO.Recordset
Dim intCount As Integer
Dim intNextCount As Integer
Dim arrEmp() As String
Dim arrAvail() As Date
Dim arrfree() As Date
ReDim arrEmp(0)
ReDim arrAvail(0)
ReDim arrfree(0)
Set rsTask = CurrentDb.OpenRecordset("select * from tasks order by taskpick;")
With rsTask
.MoveFirst
intNextCount = 1
While Not .EOF
If (!employee & "") <> "" And IsNull(![avlto]) = False Then
ReDim Preserve arrEmp(UBound(arrEmp) + 1)
ReDim Preserve arrAvail(UBound(arrAvail) + 1)
ReDim Preserve arrfree(UBound(arrfree) + 1)
arrEmp(UBound(arrEmp)) = !employee
arrAvail(UBound(arrAvail)) = ![avlto]
arrfree(UBound(arrfree)) = ![freeat]
Else
For intCount = intNextCount To UBound(arrEmp)
If arrAvail(intCount) > !taskpick Then
.Edit
!employee = arrEmp(intCount)
![avlto] = arrAvail(intCount)
![freeat] = arrfree(intCount) + ![tasktime]
.Update
intNextCount = intNextCount + 1
If intNextCount > UBound(arrEmp) Then intNextCount = 1
Exit For
End If
Next
End If
.MoveNext
Wend
End With