*!* Make a table to hold the records we accumulate *!* Don't want to add to Absence table right away *!* because that will give us more junk to sort through! SELECT Absence COPY STRUCTURE TO NewTable.dbf && Don't copy index *!* Go through your list of employees one by one SELECT Employee SCAN cEmployeeTable = Employee.Empno IF FILE(Employee.Empno) USE (Employee.Empno) IN 0 ALIAS EmployeeTable MyEmpNo = Employee.Empno *!* Part 1 - Get records missing from Absence *!* and put them in NewTable till we're done SELECT ; MyEmpNo AS Empno, ; EmployeeTable.DATE, ; EmployeeTable.CODE ; FROM EmployeeTable ; WHERE ; (MyEmpNo + ; DTOS(EmployeeTable.DATE) + ; EmployeeTable.CODE) ; NOT IN ; (SELECT Absence.Empno + Absence.DATE + Absence.CODE ; FROM Absence) ; INTO CURSOR Temp1 SELECT NewTable APPEND FROM DBF("Temp1") *!* Part 2 - Add missing records to individual employee tables SELECT Absence.DATE, Absence.CODE ; FROM Absence ; WHERE Absence.Empno = MyEmpNo ; AND (DTOS(Absence.DATE) + Absence.CODE) ; NOT IN ; (SELECT DTOS(EmployeeTable.DATE) + EmployeeTable.CODE ; FROM Absence) ; INTO CURSOR Temp2 SELECT EmployeeTable APPEND FROM DBF("Temp2") ELSE * Is lack of a table a problem? ENDIF ENDSCAN *!* Now put those records we've been holding *!* into Absence where they belong. SELECT Absence APPEND FROM NewTable.dbf