NetTalk Central

Author Topic: On inserting a record add another record to another table  (Read 3415 times)

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
On inserting a record add another record to another table
« on: August 14, 2012, 04:27:07 AM »
Please can anyone help i am trying to insert a record but would like to insert another record in another table using values from the first record

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11263
    • View Profile
Re: On inserting a record add another record to another table
« Reply #1 on: August 14, 2012, 06:01:27 AM »
You should probably use the PostInsert routine in the form, to add your own code to add the secondary records.

cheers
Bruce

olu

  • Sr. Member
  • ****
  • Posts: 352
    • View Profile
    • Email
Re: On inserting a record add another record to another table
« Reply #2 on: August 14, 2012, 06:29:16 AM »
Hi bruce thanks for the reply but then how do i handle auto increment id on the othe table and also because these files are going to be related how do i get the id number of the table that i am on at the moment which is also set to auto-increment?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11263
    • View Profile
Re: On inserting a record add another record to another table
« Reply #3 on: August 14, 2012, 06:47:43 AM »
basically, you do it the way you would do any clarion code. In the Post Insert the insert has been done, and _usually_ the parent field auto-increment has been set. (There's a file driver switch you should set if you're doing SQL). The child table auto increment is done for you when yo do a .Insert on the child table. But of course prime the child record linking fields to the parent table id.

cheers
Bruce