Try:
Nic;o)
Code:
function fncBilling()
Dim db As Database
Dim rsB As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim rs2 As DAO.Recordset
Set db = CurrentDb
Set rsB = db.OpenRecordset("select distinct Billing_ID from Accounts")
if rsB.eof then exit function ' No billings...
while not rsB.eof
Set rs1 = db.OpenRecordset("select * from Accounts where Billing_ID =" & rsB!Billing_ID)
if rs1.eof then exit function ' No employees
Set rs2 = db.OpenRecordset("select * from Assign where Billing_ID =" & rsB!Billing_ID)
if rs2.eof then exit function ' No billing data
rs1.MoveFirst
rs2.MoveFirst
Do While Not rs2.EOF 'Loop through billing
rs2.Edit
rs2![EmpID] = rs1![Employee_ID]
rs2.Update
rs1.MoveNext
' Test no more employees, if so start again
IF rs1.eof then
rs1.movefirst
endif
rs2.MoveNext
Loop
rsB.movenext
Loop
rsB.Close
rs1.Close
rs2.Close
Set rsB = Nothing
Set rs1 = Nothing
Set rs2 = Nothing
Set db = Nothing
End Function
Comment