Hi everyone,
I've been using access for several years and am working on a build to assign specific auditors to employees each month. Everything is complete except for one caveat which is each employee must have 4 audits complete once each month, but each must be done by a different auditor (i.e. an auditor can perform only one evaluation per employee). The trouble is I have not been able to find anyone who knows how to do this at work or any boards I have used online so far.
Below is the ADO statement that I built:
Sub AssignInvoicesToPersonnel()
Dim rstStrat As DAO.Recordset, rstInvoices As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM tblInvoices WHERE ReviewerID Is Null;"
Set rstInvoices = CurrentDb.OpenRecordset(strSQL)
If rstInvoices.RecordCount > 0 Then
rstInvoices.MoveFirst
strSQL = "SELECT * FROM tblStrat ORDER BY Rnd([Crew_ID]);"
Set rstStrat = CurrentDb.OpenRecordset(strSQL)
If rstStrat.RecordCount > 0 Then
rstStrat.MoveFirst
While Not rstInvoices.EOF
rstInvoices.Edit
rstInvoices!ReviewerID = rstStrat!CREW_ID
rstInvoices.Update
rstInvoices.MoveNext
On Error Resume Next
rstStrat.MoveNext
On Error GoTo 0
If rstStrat.EOF Then
restStrat.MoveFirst
End If
Wend
Else
MsgBox "ERROR: There are no reviewers to assign to evals"
End If
rstStrat.Close
Set rstStrat = Nothing
Else
MsgBox "There are ....
End If
rstIncoices.Close
Set rstInvoices = Nothing
End Sub"
For the statement above, my "tblInvoices" has a field titled "Employee_Name" and what I want to do is add a statement that says when updating the next Employee Name field with a Reviewer Id, if that same Reviewer Id has already been assigned to a previous evalulation for the same Employee Name, then to skip to another Reviewer Id. Does that make sense?
Thank you in advance for any help!!!