Run Button

I’m trying to build a run button that when pressed change the value of a field of the selected records, but I have some problems with the sc_exec_sql

I currrently have

$arr=[i];
[total_chked][$arr]={OT};
[i]++;
sc_exec_sql ( UPDATE ‘CABECERA OT’ SET ‘ORDEN CERRADA’ = ‘1’ WHERE OT={OT});

The field ORDEN CERRADA is a YES/NO Field and CABECERA OT is the table that generates the grid

Thanks in advance

1 Like

Solved avoiding spaces in table and field names, now I have another problem, I want to update a field with today date but when i try it instead of today date April 1 2014 de date inserted is June 22 1894.

My code is:

$arr=[i];
$dat=date(“d-m-Y”);
;
[total_chked][$arr]={OT};
[i]++;
sc_exec_sql (“UPDATE CABECERA_OT SET CERRADA=1, FECHA_CIERRE=$dat WHERE OT={OT}”);

Thanks in advance

Hi,
in the OnRecord event you just have to save the id of the checked record.

[checked][] = {OT}; // you don’t need a counter

In the OnFinish event you have to prepare your data to be written to the database.

if(count([checked]) > 0)
{
$ot_list = “(”.impolde(’,’,[checked]).")";
sc_exec_sql ( UPDATE CABECERA OT SET ORDEN CERRADA = ‘1’ WHERE OT IN $ot_list); // use the left tick marks ` around your table fields.
}

That should do it.

jsb

Edit:

Well you just beat me by a few. Nevertheless change the FECHA_CIERRE=$dat statement to FECHA_CIERRE=CURDATE()

[QUOTE=penguinale1980;22519]Solved avoiding spaces in table and field names, now I have another problem, I want to update a field with today date but when i try it instead of today date April 1 2014 de date inserted is June 22 1894.

My code is:

$arr=[i];
$dat=date(“d-m-Y”);
;
[total_chked][$arr]={OT};
[i]++;
sc_exec_sql (“UPDATE CABECERA_OT SET CERRADA=1, FECHA_CIERRE=$dat WHERE OT={OT}”);

Thanks in advance[/QUOTE]

If you are using MySQL then the dateformat should be Y-m-d afaik.

I’m Using MS Access

Solved changing the code to:
$arr=[i];

[total_chked][$arr]={OT};
[i]++;
sc_exec_sql (“UPDATE CABECERA_OT SET CERRADA=1, FECHA_CIERRE=now() WHERE OT={OT}”);

Now I will try to add an accep cancel routine to manage the changes