I have two tables in MS Access. They are related (to the same Employee, common key = EmployeeID) but although they have many of the same data elements they must be stored and maintained separately. One table that is already populated (Employees) that contains the values I need, and another table with the blank fields (W-4). I need to populate the table with the blank fields (W-4) with the data from the elements of the same name from the table already populated (Employees).
Based on the above, I read from another thread that I can use an UPDATE statement, but use an inner join to get the data I need from table B to fill in table A:
UPDATE [Employees] INNER JOIN [W-4] ON [Employees].ID = [W-4].EmployeeID
SET [W-4].field1 = [Employees].field1, etc etc etc
WHERE [Employees].EmployeeID = Form!ID;
I tried this in the MS Access Query (QBE) tool, and had mixed success: 1. It works if there's a record with the shared key in the target table 2. It doesn't work if there's no record at all for the shared key.
I read elsewhere on a different thread that, since I do not have (in most cases) any records in the target table with the shared key, that I would first have to do an INSERT, to get data populated initially, not an UPDATE.
So the reality is, I've got to do both - an INSERT when there's no data, or an UPDATE if there is data in the target table.