Form with 2 or mrer tables

I have 3 tables:
person (id, name, adrress, number, code, …)
physical person (id, last name, nick, docs…)
legal person (id, company name, state registration,…)

how can make one form that a can imput data in two tables :
person (id, name, adrress, number, code, …)
physical person (id, last name, nick, docs…)

or

person (id, name, adrress, number, code, …)
legal person (id, company name, state registration,…)

i hope i m been clerly!! my english is better when I’m talkinking…

You can use one table to generate your form. Then you need to apply other fields you need as custom fields. In the event onafterinsert you can add the sql statement to put your data into the second dataset. If you have created the event you can take a code snippet from the menu on the right (insert data into another table)

I created the new fields and the event, and I have this code in Scriptcase:
/ **

  • Insert a record in another table
  • /

/ / SQL statement parameters
‘my_table’ = $ insert_table / / Name of the table
Insert_fields $ list = array (/ / Field, add as needed
‘field_1’ => “‘new_value_field_1’”
‘field_2’ => “‘new_value_field_2’”
);

/ / Insert Record
$ Insert_sql = ‘INSERT INTO’. $ insert_table
. ‘(’. Implode (’,’, array_keys ($ insert_fields)). ‘) "
. ‘VALUES (’ implode (’,’, array_values ​​($)) Insert_fields… ‘)’;

sc_exec_sql ($ insert_sql);

But the main table does all the inserts properly, but nothing happens in the second table, then inserted!

Lets supose that I have a main table with two fields and the other one table with 3 more fields: (id, city, state)

how would the code?

Thanks again