Hi all,
I am using the given code to update a set of data which partially meets my need.
1) I want rsemp recordset to be sorted based on "freeat" as soon as update event occurs
2) e.g. if first employee is free before the second employee the next loop should show first employee's name for the next task rather than showing second employee's name ( Which is currently happening is there a way to achieve this order)
I am using the given code to update a set of data which partially meets my need.
1) I want rsemp recordset to be sorted based on "freeat" as soon as update event occurs
2) e.g. if first employee is free before the second employee the next loop should show first employee's name for the next task rather than showing second employee's name ( Which is currently happening is there a way to achieve this order)
Code:
Set rsTask = CurrentDb.OpenRecordset("select * from tasks where employee is null order by taskpick;")
With rsTask
.MoveFirst
Set rsemp = CurrentDb.OpenRecordset("select ests.* from ests order by freeat", dbOpenSnapshot)
rsemp.MoveFirst
Do While Not rsTask.EOF
.Edit
!employee = rsemp!ename
![avlto] = rsemp![avlto]
![freeat] = DateAdd("n", Nz(rsTask![tasktime]) * 60, DMax("[freeat]", "ests", "[Ename]='" & rsemp!ename & "'"))
.Update
rsTask.MoveNext
rsemp.MoveNext
If rsemp.EOF Then
rsemp.MoveFirst
bolsecondpass = True
End If
Loop
End With