1 2 Previous Next 17 Replies Latest reply on Nov 20, 2013 6:20 AM by matshawk

    Button action

      Title

      Button action

      Post

           Hello

           Is it possible with a button in one layout create a new record in an other layout and at the same time transfer the information from some fields in the first layout to the second?

            

           /Mats

        • 1. Re: Button action
          SteveMartino

               Yes.  If you provide more information, more help will arrive :) 

               Without knowing the details of what you wish to accomplish, in the first layout, the fields you want to transfer you will need to capture with Set Variable Script steps (most likely including the primary key). Think of this as a 'copy' function.

                Then switch layouts, create new record, and use Set Field Script steps in the appropriate fields.  Think of this as your 'paste' function.

               This will most likely be one script, attached to the button.

          • 2. Re: Button action
            philmodjunk

                 Please note that "layout" and "table" are two different things in FileMaker. If each layout is based on a different table, then Steve has described the typical method used to create a new record in the other layout's table. But please note that you can have two layouts based on the same table. Please note that it is also not the only way to do this either.

                 Freeze Window
                 Set Variable [$ID ; Layout1Table::__pkLayout1TableID]
                 Go to Layout ["Layout2" (Layout2Table) ]
                 New Record/Request
                 Set field [Layout2Table::_fkLayout1TableID]

            • 3. Re: Button action

                   Hi

                   Thanks for your answers. Im not that of an expert in FM so if you could keep your answers very simple i would be grateful! 

                   I attach an example of how it could look like. Very simple, but i hope you get my point.

                   I start to fill in the Layout "Analyze" and when that is done i press the button and a new record is created in "Follow up" and the values from "Analyze" are transferred to that record in "Follow up". If it's possible to switch to "Follow up" at the same time would be perfect!

                   If it's possible, please make it work in the example file so i can study that for my real file.

                   Best regards

                    

                   /Mats

              EDIT: Hmmm is it not possible to upload a fp7 file?

              • 4. Re: Button action
                philmodjunk

                     To repeat: a layout and a table are not the same thing.

                     WHY do you need to create a new record in analyze and copy the values to it from Follow up? What is that supposed to do for you? You may not need to create a new record at all and you may not need to copy over any data in order to get it to appear on both layouts after entering it on the first layout.

                Hmmm is it not possible to upload a fp7 file?

                     It is not. If you check the list of permitted file types a FileMaker file is not one that you are permitted to upload. But you can upload the file to a free file sharing site such as Drop Box and then post the down load link for the file in your next response here.

                • 5. Re: Button action

                       Hi

                       We have the two different Layouts in two different Excel files today. First you fill in the "Analyse" and then the "Follow up". This can be made on different days and by different people.

                       I am now transforming this to FM (11) and it would be good if some of the fields where transfered from "Analyze" to "Follow up" automatically.

                       I attach two images, and maybe you understand. 

                       Best regards 

                       /Mats

                  • 6. Re: Button action
                    philmodjunk

                         FileMaker is not a spreadsheet program. It's internal structure is very different. A good working knowledge of tables, layouts and Tutorial: What are Table Occurrences? will help to understand how to take advantage of those differences.

                         If you define two tables, you can link them in a relationship. With the correct relationship, a layout based on the second table can include fields from the first table and show the data that has been entered into them on the other layout.

                         You might define this relationship:

                         Table1::__pkTable1ID = Table2::_fkTable1ID

                         For an explanation of the notation that I am using, see the first post of: Common Forum Relationship and Field Notations Explained

                         This is a "one to many" relationship. One record in Table1 can be linked to multiple records in Table2. With this relationship in place, you can add fields from Table1 to the layout for Table2 and they will show the data from the related table1 record.

                    • 7. Re: Button action

                           Hi

                           Thanks for your answers and efforts but this is way to complicated for me.

                           /Mats

                      • 8. Re: Button action
                        philmodjunk

                             Both layouts can also be based on the same table and you can then design each layout to display different groups of fields. In that case, the fields you circled are one and the same fields and the data entered on one layout will be visible on the other.

                        • 9. Re: Button action
                          CekariYH

                               Mats, every table you create belongs to a specific  layout so if you don't want to create relations-ship between the 2 tables as Phil suggested you need to when you press the button:

                               1. Copy each of the fields to either a global variable named as $$"name" or create a global Table-variable that works like a one-record global-variable sort of…

                               In Swedish: Tabeller kan inte passa fält mellan sig hur som helst, varje tabell med dess fällt är knutna till en layout, så när en layout är öppen kan inte fält från en annan tabell ses eller användas om man inte relaterar tabellerna med varandra. Relatera betyder att man knyter ihop 2 eller flera tabeller med varandra via gemensam fält, typ ett index-fält.

                               Om man inte relaterar måste man kopiera värdena från de fält du vill ha i en annan tabell till antingen globala minnes-variabler via Ange variabel typ $$"namn". eller skapa en 3:e tabell där du sätter fälten du skapar där som variabler vilket då blir variabler som sparas till skillnad från $$-variablerna som nollställs när du stänger av programmet.

                               Oavsett vilken variabel-typ du använder så måste du när du trycks på knappen utföra minst följande:

                               Ange Variable $$Fält1 = tabell1::fält1

                               Ange Variable $$Fält2 = tabell1::fält2

                               osv

                               eller fält-variabler i tabell3

                               Tilldela Fält tabell3::fält1 = tabell1::fält1

                               Tilldela Fält tabell3::fält2 = tabell1::fält2

                               osv.

                               Sedan används Gå Till Layout för att gå till den layout som har Tabell2

                               Ny Post/sökpost

                               Tilldela Fält tabell2::fält1 = tabell3::fält1 eller Tilldela Fält tabell2::fält1 = $$Fält1 osv

                               Verkställ Post/sökpost för att spara den nya posten.

                               Mycket enkelt förklarat, då man oftast behöver göra kontroller att allt gått rätt till, så inga fält är tomma eller så när dom inta ska vara det eller annat som kan gå snett… men det är en annan fråga. :-)

                          • 10. Re: Button action
                            philmodjunk
                                 

                                      every table you create belongs to a specific  layout

                                 That isn't really the case. You can have many layouts that all "belong" to the same table. Every layout, on the other hand is based on a specific table by selecting a Tutorial: What are Table Occurrences? name from those listed in Manage | Database | Relationships.

                            • 11. Re: Button action
                              CekariYH

                                   @ Phil… True, I stand corrected… Just tried to make it simple but thanks for correcting me as it was misleading in the way i wrote it.

                              • 12. Re: Button action

                                     Hi

                                     Thank you all for your answers. A bit to complicated for me as i said before, so i tried to do something simple...

                                     In the button setup i added a script that just copied and pasted from one layout to the other, see pic.

                                      

                                     Maybe not the smartest or the most sofisticated way but it works for me.

                                     Best regards

                                     /Mats

                                • 13. Re: Button action
                                  CekariYH

                                       A lot of swapping layouts back and forth there… read in the help for FMP about how to make $$varibles or Global Field variables instead, much faster and safer, and only one layout swap.

                                  • 14. Re: Button action

                                         Hi again

                                         With the help from  CekariYH (in swedish ;)) I got it right with  $$Variables!

                                    Thanks to all of you for your inputs!

                                    Best regards

                                         /Mats

                                    1 2 Previous Next