6 Replies Latest reply on Jun 22, 2012 3:37 PM by heath

    Scripting issue printing a form...



      Scripting issue printing a form...


      Hello -

      Thanks in advance for any advice you may be able to give me.  I have set up a database that analyses field data and I have constructed a form (within a separate layout) that will print a formal report of the findings.  The user is offered a button to load the form for the current record in a new window and thus from there they can print.  I have having a couple of issues.  One, when the form loads in a new window the database window also resizes to the exact same size behind the new form window.  Subsequently when you close the form window the database window has to be re-expanded to fit the monitor.  I built this database on a Mac and moved it to an XP machine for the client.  This problem only surfaced when moving to the PC.  On the mac the script works fine!  Secondly, the form layout shows all records, not pulling up just the current record that the client wants to print a report on.  Thus, once the printing layout opens in its new window it begins at the first record and the client must click forward until they find the corresponding record.  How do I make it so just the record being viewed is displayed and how do I stop all windows from resizing, ie: the printing layout windows opens above the database without disturbing its current size.

      The script I am currently using that is attached to print button within the database can be viewed in the attached screenshot!

      Thanks again



        • 1. Re: Scripting issue printing a form...

          In stead of using a go to related record step I would set the current records ID as a variable (I hope your table has a Unique ID's field as a number field set to auto enter a serial number.)

          And then go to the other layout to perform a find on that variable.

          Like so:

          Set Variable [ $ID ; Table::ID ]
          Go To Layout [Your Print Layout]
          Enter Find Mode [Uncheck Pause button]
          Set Field [ Table::Id ; $ID ]
          Set Error Capture [On]
          Perform Find
          If [Get (Last Error (does not equal) 0 ]
            Go To Layout [Original]
            Exit Script
          End If
          Enter Preview Mode
          Pause Script [Indefinately]
          Enter Browse Mode
          Go to Layout [Original]

          For the resizing: Does your "go to related record" script step open a new window?
          Anyway, with my script you shouldn't have that problem.

          Note that the Set Variable needs two values, the name and the field you are using to set that value.

          A variable name always starts with a "$" sign.

          • 2. Re: Scripting issue printing a form...

             Hi DaSaint-

            Thanks for the quick reply.  I will do some testing with your script, looks great.  I have never used this approach and am relatively new to all of this so once again thank you.  I have indeed used an ID.  With regards to resizing, I just realized my screen capture cut off the end of my script where infact I did use a new window at the end of my "go to related record".  Don't know why I having an issue with it on PC.  Nonetheless, like you said it will not be an issue with yours.

            I will update my findings soon,


            • 3. Re: Scripting issue printing a form...

              Go to related records can be used for this quite nicely, but you need a relationship that matches your current record uniquely to itself in order to do that. It doesn't appear you have that here. You can use DaSaint's approach or set up that needed relationship.

              To handle the window resize issue which, as you've discovered, is a Windows only issue, you can run this database without the windows maximized (I don't like that option myself, but it works) or you can add code like this:

              New Window step or Go To Related records step with New window option here
              If [ Get ( SystemPlatform ) = 2 ]
                Move/Resize Window [ Get ( FileName ) ; Current File ; Height: Get ( ScreenHeight ) ; Width: Get ( ScreenWidth ) ; Top: 0 ; Left: 0 ]
              End IF

              Then use code such as:

              If [ Get ( SystemPlatform ) = 2 ]
                  Adjust Window [Maximize]
              End IF

              To remaximize the windows.

              With Filemaker Advanced, you can even set up a custom menu on your report layout such that the close window menu option performs a script with that closes the window and then uses this code to maximize windows.

              • 4. Re: Scripting issue printing a form...

                 Ok - Everything works great except for one part.  I am having problems introducing the variable into line 4 "Set Field [...]".  As you will see below in my screen shot I am only able to enter the Table and field, not the ";$ID" at the end.  How do I enter the semicolon and then the variable.  You will see what I mean in the screen shot.




                • 5. Re: Scripting issue printing a form...

                  When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                  • 6. Re: Scripting issue printing a form...

                     Thanks everyone -

                    Everything is working great!!!