I have two tables, Timesheet and Work. Each Timesheet record can be associated with multiple Work records. Each Work record will only be associated with one Timesheet record:
What I want to do is add a new Work record, and if a Timesheet with matching Staff ID and PG exists, then make these related by putting the Timesheet:ID into the Work record. But if there is no Timesheet with the same Staff ID and PG, I want to automatically create one and then put its Timesheet:ID into the Work record.
How should I do this? Or, alternatively, am I being a complete idiot for wanting to do this?