5 Replies Latest reply on May 15, 2009 10:09 AM by DaveParry

    Copy Value field.



      Copy Value field.


      I need to copy 6 fields from one layout to another, both using the same table, using a button,.

      I have written a script which creates a new record, and then uses the following commands.

      Go to layout["Orders"(orders)]

      Copy[select; Orders::Value]

      Go to layout["Balance"(Balance 2)]

      Paste[Select; Balance 2::Income]


      This is repeated for the 6 fields.


      It works Fine apart for one field (a value Field), where it repeats the field used previously, instead of the value.

      There is another value field used where it works ok.


      I cant see anything wrong with the script, but cant understand why it wont copy and paste that value field.


      Can anyone shed light on this, or is there a better way to transfer the data than this one.

        • 1. Re: Copy Value field.

          Go to layout["Orders"(orders)]

          Set Variable [ $field1; Orders::Value ]

          Set Variable [ $field2; Orders::Field2 ]

          Set Variable [ $field3; Orders::Field3 ]

          Set Variable [ $field4; Orders::Field4 ]

          Set Variable [ $field5; Orders::Field5 ]

          Set Variable [ $field6; Orders::Field6 ]


          Go to layout["Balance"(Balance 2)]

          New Record

          Set Field [ Balance2::Income; $field1 ]

          Set Field [ Balance2::Field2; $field2 ]

          Set Field [ Balance2::Field3; $field3 ]

          Set Field [ Balance2::Field4; $field4 ]

          Set Field [ Balance2::Field5; $field5 ]

          Set Field [ Balance2::Field6; $field6 ]

          Comit Record []

          • 2. Re: Copy Value field.

            Yes there are better ways to transfer the data. Copy and Paste are primarly included so that very old version of Filemaker will continue to work if they are converted to the latest version of filemaker.


            Copy and Paste script steps only work if the field they reference is present on the current layout. That's the most likely explanation of why it doesn't work.


            In any case, try this script instead:


            Set Variable[$Field1, Orders::Value]

            Set Variable[$Field2, Orders::field2name]

            Set variable[

            #and so forth until you've stored all your values in separate variables.

            Go to layout [Balance (Balance 2)]

            Set Field [Balance 2::income, $Field1]

            Set FIeld [Balance 2::field2name, $field2]

            Set Field [

            #and so forth until all values are stored in the current record of the Balance layout.


            Set Variable and Set Field don't rely on the field being physically present on the current layout and won't affect any data your user may have copied to the system clipboard.


            You may have other issues that are keeping your script from working that involve your tables, relationship and what record is current on each of your layouts. I'd need to know more about your database design before I could help you investigate those.

            • 3. Re: Copy Value field.

              "or is there a better way to transfer the data than this one."


              Why are you transferring data at all?  With a key field, you can simply relate them and 1) display the field data through the relationship or 2) copy only the key and then use Set Field[] to transfer the remaining field data.  I would be inclined to think a relationship (which eliminates redundant data) might be worth considering.

              • 4. Re: Copy Value field.

                Keep in mind that there ARE times when copying data from multiple fields is necessary (or preferred).  But it is usually only an advanced technique.  And I suspect, since you are using copy/paste, that you may not need this type of complexity.


                If your first table has a unique ID (and ALL tables should), add the same ID field in your second table and create a relationship using =.  Then you can simply go to your other table (taking the uniqueID with you from this table in form of script variable) and insert it into the new table (in a field with same ID name).  Then just place those fields directly on your other table's layout from the first table.  No duplicate data required.

                • 5. Re: Copy Value field.

                  Thanks Mr Vodka and Phil.

                  Thanks La Retta, I would look at using key field, but as I understand the prev. and have already used it and its working, think I will leave it as it is.