Announcement

Collapse
No announcement yet.

Run Button

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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

    Comment


    • #3
      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()
      Last edited by jsbinca; 04-01-2014, 09:53 AM.

      Comment


      • #4
        Originally posted by penguinale1980 View Post
        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
        If you are using MySQL then the dateformat should be Y-m-d afaik.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          I'm Using MS Access

          Comment


          • #6
            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

            Comment

            Working...
            X