Hello folks,
Can we call a form for a specific entry in the database by providing the where condition to the sql request? It seems to be possible for the grids with the sc_select_where macro (even if it’s still not clear how to do it for me), but can we do the same with forms?
Here are some details about what I’d like to do (but I’ve also others places where I’d like to do things like this):
I have a form called “people” wich refer to a mysql database containing a table for peoples and a sub-table with some details with a master/details relationship.
When I create a new people, I need to perform some specific task like creating new entries in the details table. To do this, I removed the standard “New” button and replace it with one of mine with some dedicated php code that I can summary like this :
$mydate=(‘Y-m-d’);
sc_begin_trans();
$sql=“INSERT INTO people (‘Name’) VALUES (’???’)”;
sc_exec_sql($sql);
$People_ID=mysql_insert_id();
sc_commit_trans();
sc_begin_trans();
$sql=“INSERT INTO peoples_details (‘People_ID’, ‘Date’) VALUES (’” . $People_ID . “’, ’ . $mydate . ')”;
sc_exec_sql($sql);
sc_commit_trans();
[global_peopleid] = $People_ID;
sc_redir(new_people);
Currently the solution that I use is that I made a copy of “people” form into a “new_people” form and I’ve added in the WHERE condition : “People_ID = [global_peopleid]”. Then I have a “onValidate” event on the new_people form wich do a sc_redir(people).
I’d like to use only one form, replacing the 2 last lines of my script by something like :
sc_redir(people, “where_contion”);
Tanks for your help.