How call a form from another form

Hello! I try to find this in forum and documentation with no results

I have 2 forms from my tables “Personal” and “Adresses” and i need call my second Form (adresses) when the data of my first Form (Personal) have been inserted.
I try with event “AfterInsert” but i dont have idea if a function do this.
I feel that is very simple but there are many option and the documentation is some poor

I hope having explained, my English is somewhat limited :slight_smile:

thank all !!

Re: How call a form from another form

Well now i know that i need a Method to do this but i need the code :stuck_out_tongue:

I create a new Method ( new_met(); ) and place in AfterInsert event in Form
But how call the next form ??

Maybe javascript works but i don’t have idea how call the form in the window.

I have a menu bar and my first Form is the default Form, if i use javascript i need to know where place the next Form.
If i create a link in a grid to call a Form i see that the javascript place teh form in "document.F3 " but can i use this code?

I need close the first form after insert and open the next form with the ID field of my first Form.

Please, i need some help !! :S

Re: How call a form from another form

Hi Greulich, have you tried sc_redir()?

I supose that you can redirect your application to the other form using sc_redir in OnAfterInsert Event…

Re: How call a form from another form

Thanks lisandrogalup !!
works ! :smiley:

Now i have another problem :frowning:

I have this code in my Form1 in onAfterinsert Event: sc_redir(form2, id_inv={id});
well, I fill the Form1 data, click on Insert button, the application redirect to other form… but the insert is not done
The autoincrement in sequence table works fine but the insert in my data table don’t. If i delete the code in “onAfterInsert” all works fine.
Wath can i do ?

Thks again ! :smiley:

Re: How call a form from another form

Several things to note here.

You can also redirect your app using Applications/Navigation and setup the Exit options.

Have you tried creating pages/tabs to have all the entry forms in the same app instead of redirecting to another app?

Back to your question:
I take it that your AutoInc field is creating a new value since AfterInsert is finished? There is a setting in Fields/FieldName/DatabaseValue. In the Insert Dropdown, set to AutoIncrement (Manual), and Force Value.

See if updating these help with your problem.
You can also try setting Initial Value to Defined Value:{id} and set Insert Database Value to Defined Value.

I have not tried this, but I believe it should work.

Regards,
Scott.

Re: How call a form from another form

You can also use the PHP function:
$lastItemID = mysql_insert_id();

To get the last value and update the value in code yourself.

Regards,
Scott.

Re: How call a form from another form

Thks ScottMartin but i use postgres and the problem was that the insert is not executing.

I solve the problem with this code in “onAfterInsert”:

sc_commit_trans(“conxDB”);
$_SESSION[‘scriptcase’][‘sc_sql_ult_comando’] = “select CURRVAL(‘form1_seq’)”;
$rsy = &$this->Db->Execute($_SESSION[‘scriptcase’][‘sc_sql_ult_comando’]);
$this->inv_id = $rsy->fields[0];
$rsy->Close();
sc_redir(form2, val_id={inv_id});

line 1: execute all pending transactions (with this i solve my insert problem)
line 2-5: extract the currentval in the sequence (i copy the code from Form2_apl.php)
line 6: redirect to the Form2 with the parameter that i need in form2

if somebody have any better code please tell me !!
Thks!