Announcement

Collapse
No announcement yet.

affect some information from one application to another one

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

  • affect some information from one application to another one

    Hello,

    I'll try to explain my problem:
    I have a container with 2 forms.
    First one contains one record of a table.
    Ex: TABLE CLIENT
    Fields: NAME ADRESS DATE ITEM
    The user can create a new record with a name, adress ans date.

    Second form contains all records of the table ITEMS :
    ITEM NAME INFORMATION
    I add a field on the form: TAG which is a checkbox (YES/NO)

    I want to add in the table CLIENT for each ITEM with TAG = YES:
    NAME ADRESS DATE ITEM

    I don't know in with event select all check records. I try to create a button in first and second form, without success.
    I give you a image of the container, because my English is so poor...

    Best Regards,
    Olivier
    Attached Files

  • #2
    Originally posted by ols03 View Post
    I give you a image of the container, because my English is so poor...
    Olivier
    Yes I guess so, as I didn't understand what you want to do

    Ok whatever I understood, if you want to add some items to each client, then you don't need a new widget or a container... a widget from another form is not good idea.

    make your item field in table 1 as double select, and point the options to auto lookup in your table 2 for items, finally display to end user only form of table 1, they can select as many items they want and save the record... you can layout your double select field and play with it to appear under your other fields...

    if that is what you want!

    Comment


    • #3
      Hello Mike,

      I don't understand too...

      The problem is if a have on the form 10 select records, i don't know how to retrie them in a select... The checked box field is not a fiels of the table ITEMS, because the checked state must be just for select some records.

      Best regards,
      Olivier

      Comment


      • #4
        Oliver, if the checkbox field is not in the same table then how you will save its data! Make a new field as items (checkbox or double-select) and make its lookup take the values from your items table and thats it! you will have the double-select field just like any other field, display normally and save the selection normally!

        Comment


        • #5
          Hello,

          I can now use checkbox!
          But i want save records in another table by sc_exec_sql.
          I have an error on the line:
          sc_exec_sql("INSERT INTO aff_cde2 (CLIENT,NCDE,RESA,DLIV,CART,CART_SOURCE,AFFINAGE,L OT,STOCK,QTE,ID) values ([clientcde],0,[resacde],[dlivcde],[cartcde],[total_cart][$x],'a',[total_lot][$x],'',[qtecde],)");

          I supposed the last field ID that i let with a comma is not correct. Simply because ID is auto-increment, i don't know how to indicate it.

          Best regards,
          Olivier

          Comment


          • #6
            I had some error, but now it's correct. I can insert on record when i put ID.
            I just have to solve the autoincrement problem.
            Olivier

            Comment


            • #7
              Just last try:
              I trie to get the last ID on my table.
              The request Under Firebird:
              select gen_id(GEN_AFF_CDE_ID, 0) from rdb$database;

              give me the last ID value of the autoincrement genrator.

              But when i try to use it in scriptcase:
              $var="select gen_id(GEN_AFF_CDE_ID, 0) from rdb$database";
              sc_lookup(rs, $var);
              $var = {rs[0][0]};
              echo $var;

              I have the errors:
              Erreur
              Undefined variable: database

              Erreur
              ibase_query(): Dynamic SQL Error SQL error code = -204 Table unknown RDB At line 1, column 39

              Erreur
              Undefined offset: 0

              Colud you help me please?
              Best regards,
              Olivier

              Comment


              • #8
                for the last id you can use MAX(id)
                if you want to insert into a field wich is autoincrement, use Null

                Comment


                • #9
                  Hello MikeDE,
                  Null is not accepted:
                  sc_exec_sql("INSERT INTO aff_cde2 (CLIENT,NCDE,RESA,DLIV,CART,CART_SOURCE,AFFINAGE,L OT,STOCK,QTE,ID) values ('[clientcde]',0,'[resacde]','[dlivcde]','[cartcde]','$carts','a','$lots','',[qtecde],NULL)");

                  Errors:
                  Erreur
                  ibase_query(): validation error for column ID, value "*** null ***"

                  Erreur en accédant à la base de données:
                  validation error for column ID, value "*** null ***"
                  INSERT INTO aff_cde2 (CLIENT,NCDE,RESA,DLIV,CART,CART_SOURCE,AFFINAGE,L OT,STOCK,QTE,ID) values ('sdsd',0,'C','2014-11-11','BG38504C','BF1152','a','45869250','',1,NULL)

                  I try uppercase, lowercase,...

                  Best regards,
                  Olivier

                  Comment


                  • #10
                    hmmm oliver, is it the same order as the database EXACTLY? I remember once by jsb he said should be in exact order. make sure your id the (null) location must be right.

                    see this post for more information about (i think) is the same
                    http://www.scriptcase.net/forum/show...-a-hint-please

                    Comment


                    • #11
                      Hello!
                      The fields are strictly in this order in database.
                      Best regards,
                      Olivier

                      Comment


                      • #12
                        Hi

                        did you try to leave it blank?

                        there is a code in the ready-made codes of sc, says: copy records to another table... have a look at it please, i used that with selected fields and worked, kept id field (auto increment in the target table) undefined in the code (didn't mention it) and it works fine... it adds the record regardless to id field.


                        Mike

                        Comment


                        • #13
                          Olivier,

                          If the database definition of the column is indeed auto-increment, then you need not pass anything. Leave the field ID out of the list, and leave the NULL out of the list.

                          Dave
                          Dave Prue
                          Code Whisperer
                          Lahar International Corp
                          www.lahar.net

                          Comment


                          • #14
                            Hello Mike,
                            The order of the values is strictly the same that the fields in database.
                            I try to do that:
                            sc_lookup(rs,"SELECT max (id) from aff_cde2");
                            $max={rs}[0][0];
                            $max = $max+1;
                            sc_exec_sql("INSERT INTO aff_cde2 (CLIENT,NCDE,RESA,DLIV,CART,CART_SOURCE,AFFINAGE,L OT,STOCK,QTE,ID) values ('[clientcde]',0,'[resacde]','[dlivcde]','[cartcde]','$carts','a','$lots','',[qtecde],'$max')");
                            }

                            It seem OK, but very long in execution.
                            Do you have any idea about that?
                            I'll try to improve that.

                            Best regards,
                            Olivier

                            Comment


                            • #15
                              I change my code:
                              sc_lookup(rs,"SELECT max (id) from aff_cde2");
                              $max={rs}[0][0];

                              for($x=0;$x<$tot;$x++){
                              $lots = [total_lot][$x];
                              $carts = [total_cart][$x];
                              $today = date('jyhis');
                              $max = $max+1;
                              sc_exec_sql("INSERT INTO aff_cde2 (CLIENT,NCDE,RESA,DLIV,CART,CART_SOURCE,AFFINAGE,L OT,STOCK,QTE,ID) values ('[clientcde]',0,'[resacde]','[dlivcde]','[cartcde]','$carts','a','$lots','',[qtecde],'$max')");
                              }

                              All is OK, that you Mike for help.
                              Olivier

                              Comment

                              Working...
                              X