I use following code to distribute accounts equally to employees from table "Assign" to table "Accounts".
The code update one by one 'EmpID' from table "Assign" to field ‘EmployeeID’ in table "Accounts".
My question is how to put Criteria in below code if there is another field e.g. 'billing_ID', in both tables? The code should match and assign accounts where 'billing' codes are same. Thanks
The code update one by one 'EmpID' from table "Assign" to field ‘EmployeeID’ in table "Accounts".
My question is how to put Criteria in below code if there is another field e.g. 'billing_ID', in both tables? The code should match and assign accounts where 'billing' codes are same. Thanks
Code:
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Set db = CurrentDb
Set rs1 = db.OpenRecordset("Accounts")
Set rs2 = db.OpenRecordset("Assign")
rs1.MoveFirst
rs2.MoveFirst
Do Until rs1.EOF
rs1.Edit
rs1!EmployeeID = rs2!EmpID
rs1.Update
rs2.MoveNext
If rs2.EOF Then
rs2.MoveFirst
End If
rs1.MoveNext
Loop
rs1.Close
rs2.Close
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing
End Function
Comment