RE/
the point is that I must insert a record into Person using
DoCmd.RunSQL("INSERT INTO...;") and also I must do the same with
Phone, but How I know the key generated for Person before?
You don't and you never will for sure.... The Max() thing probably works most
of the time if there aren't that many users banging on it, but it's not
technically tight.
I do one of two things, depending on the situation:
1) If it's a small record, I just do a .AddNew via DAO.
2) If it's a big record I might do a .AddNew for just an empty shell of a record
from which I capture the ID. Then I follow the .Update up with running a query
to fill in the rest of the info.
3) If there's going to be a lot of this going on, I change from AutoNumber to
just a Long for the PK,and create a table: zstblRecordNumberLatest. Then I go
to that table and increment a field in it to get my next ID number before adding
a record.
Option 3 has worked pretty well for a number of years. It adds some complexity
at first, but once you get a function fully debugged, all you have to code is
something like NewID = RecordNumberNextGet("TimesheetID").
--
PeteCresswell