3 Replies Latest reply on Mar 27, 2009 6:14 AM by bb69

    Copy Multiple Fields



      Copy Multiple Fields




      I am a newbie to FM Pro.  I am taking over a database from someone else. I want to perfrom a search of the database to compare the amount of spare parts to the minimum amount of parts require to have as spares and then generate a list in a separate table. I have two tables in my database.  The first table is a parts inventory table which has the parts separated by project type.  I had to create the minimum parts field for each project.  That part worked fine.  I created a script to search all the records and compare the minimum parts field to the amount of spare parts available and then show the results of the records found.   In my second table, I created the fields I wanted to copy from the parts inventory table.The copy portion of my script is similar to this:



         Copy first field

         go to layout of second table

         new record

         Paste field

         go to  layout of first table

         go to next record(exit if last)

      end loop


      I have about six fields to copy.   I would go back and forth between layouts to copy each field I need to the second table before moving on to the next record. Two of the fields are easy to copy from while the four others depend on the certain project fields.   Each of the four fields would have to copy from one of ten possible fields, depending on which project it is under.  


      Is there an easier way to copy and paste fields from one table to another than going back and forth between tables?  




        • 1. Re: Copy Multiple Fields



          Thank you for your post.


          There are a couple of ways to do this, and it depends what works best for you.


          The first method is a straight import into the second table.  That is, select the second table, pull down the File menu and select Import records, selecting the same database file and choosing the first table, and then aligning the fields from the first table with the fields in the second table.


          Another option is to not use the Copy command, but instead, assign the fields to variables.  It is probably easier to show you than explain.  Using your script as an example, the script may be modified to look like the following:



          Go to Layout [ <first table layout> ] 

          Go to Record/Request/Page [ First ]


             Set Variable [ $field1 ; <first field> ]

             Set Variable [ $field2 ; <second field> ]

             Set Variable [ $field3 ; <third field> ]


             Go to Layout [ <second table layout> ]

             New Record/Request


             Set Field [ <first field in second table> ; $field1 ]

             Set Field [ <second field in second table> ; $field2 ]

             Set Field [ <third field in second table> ; $field3 ]


             Go to Layout [ <first table layout> ]

             Go to Record/Request/Page [ Next ; Exit after last ]

          End Loop




          I only showed you three fields, but you can expand it to what you need.


          If you need clarification for any of the steps above, please let me know.



          FileMaker, Inc.


          • 2. Re: Copy Multiple Fields

            2 good reasons not to use copy and paste:


            1. Copy and Paste only function correctly if the field referenced is present on the current layout.
            2. Copy will replace the current contents of the clipboard with the field contents that it copies. If a user copies info to the clipboard and then triggers your script, your script will destroy what the user initially copied. This results in very unhappy users!
            • 3. Re: Copy Multiple Fields



              Thanks for the information.  The second option worked well.