How can I get the auto incremental PK key value?

Hi, everyone.
I wish that when a user adds a record to AA table,all record of BB table automatically being append to CC table
I wish that when a user update a record of AA table, relational records of CC table being updated with BB table.
PK value of AA table is auto incremental value. that PK key value are using in CC table rebuilding.
How can I get the PK key value?
Where do I put the sql statement?
Thank you.

You question is a bit unclear. The best way to do it is to setup PK and Autonumbering/Autoincrement in database. Then whatever the SQL sever is it will take care of that for you.
You just have to make sure to build proper relationship between your AA and BB tables. SC does an excellent job taking care of all the updates for ChildRecords. If you need to know the PK value ahead of time (before your AA table record is saved you can add record to the secondary table with nothing but PK value, then update the rest of the record later (i.e. when the Parent table AA record is saved).

ARTHUR

Hi, ARTHUR

Thank you.
I’m sorry I failed to write English well.
It is similar to the one-to-many relationship.
I know about the relationship between order and order_item.
But what I want is not the same as one-to-many relationship.
They are each a separate table.
For example, the AA table is SUMMARY / TOTAL of salary table.
The BB TABLE is EMPLOYEE LIST, the CC table is SALARY detail table.
are you understand ?
If user insert a new monthly salary description on AA TABLE, with the PK value of the registered AA TABLE
BATCH process start to append the list of the BB TABLE to CC TABLE.
I’ve tried several times, PK value not found the point at which the generation of AA TABLE.
autoincrement PK value is still estimated at zero in the OnAfterInsert event.
When the transaction finished, i watching the new value be entered in field of PK latedly.
I am wandering in this area.
Please give me help.

human