3 Replies Latest reply on Oct 26, 2008 4:05 PM by davidhead

    Button Script

    seanhunt

      Title

      Button Script

      Post

      I've created two layouts for an invoice table which is part of a larger relational database. One layout is for the data input named 'Invoices' and the second layout is the actual printable invoice named 'Create Invoice'. What I have been trying to do is to create a button that I could use on the first layout which allows me to search for the one invoice related to the current record. At the moment when I go into the second layout it has obviously created all the invoices for the database and I would then do a find. I was hoping to neaten the process with a button script. Is there a simple script that I could use for this?

      Thanks in advance,

       

      Sean

        • 1. Re: Button Script
          TSGal

          Sean:

           

          There are a couple of ways to handle this.  Let's think of what you are trying to accomplish, and then put it into a script.

           

          If the button is pressed, we want to take the value from an "Invoice" field, copy it to the clipboard, switch to the other layout, enter Find mode, paste from the clipboard into another Invoice field and perform the find.  Therefore, the script might look something like this:

           

          Copy [Select; <Invoice field>]

          Go to Layout ["Layout #2"]

          Enter Find Mode []

          Paste [Select; <related Invoice field>]

          Perform Find []

           

          You can then attach this script to a button.

           

          Does this make sense?

           

          Try this out, and let me know if you run into any difficulty.

           

          TSGal

          FileMaker, Inc. 

           

          • 2. Re: Button Script
            seanhunt
              

            TSGal,

             

            It worked like a dream! Thank you so much!! It is a much neater method than I had managed thus far and I think I just about follow what you did.

             

            Brilliant!

             

            Cheers,

             

            Sean

            • 3. Re: Button Script
              davidhead
                

              TSGal wrote:

              If the button is pressed, we want to take the value from an "Invoice" field, copy it to the clipboard, switch to the other layout, enter Find mode, paste from the clipboard into another Invoice field and perform the find.  Therefore, the script might look something like this:

               

              Copy [Select; <Invoice field>]

              Go to Layout ["Layout #2"]

              Enter Find Mode []

              Paste [Select; <related Invoice field>]

              Perform Find []

               


              Ummm, it is generally accepted that you should not mess with a user's clipboard without their knowledge ;) Therefore you would usually do this by setting and using a variable:

              Set Variable [$invoice; <Invoice Field>]

              Go to Layout ["Layout #2"]

              Enter Find Mode []

              Set Field [<related Invoice field>; $invoice]

              Perform Find []

               
              Just better programming. ;)