1 Reply Latest reply on Jan 9, 2012 3:23 PM by philmodjunk

    Open Report in New Window



      Open Report in New Window


      I have created a few reports for printing in an application I am developing.  Ideally, the user would select a report, via a button, and the report would open in a new window.  From there, the user can print the report and simply close the window.

      I can see how to open a new window - but not direct it to a specific layout (the report selected).  Or...  I can use the button to go to the layout (the report selected), but it isn't in a new window.  Using this method, I would need to create a way for the user to navigate back - which I don't want to do.

      Is there a simple way to have the user select the button for the report he wants, then have it open a new window showing that report (layout)?  Thanks!

        • 1. Re: Open Report in New Window

          Each time you open a new window in Filemaker you get a new set of found sets for every table occurrence for the new window. Thus, you have to do three things:

          1) open the new window

          2) go to the correct layout to display these records

          3) pull up the records needed for your report in a found set.

          All three aspects can sometimes be done with a single Go To Related Records step if you can use a relationship to define the set of records needed for your report. If not, your script would look something like this:

          Set Variable [....//capture all values needed for your find criteria in variables unless the data is already in a global field]
          New window
          Go to layout [ Specify layout for new window here]
          Enter Find mode [] //clear the pause check box.
          Set field [  //use set field steps to set up search criteria for report copying data from variables and global fields]
          Set error capture [on] //keeps "no records found" dialog from interrupting your script if no records are fond.
          Perform Find[]
          Sort Records[//optional, may be needed to get correct results for report]

          Closing the window then returns you to the original window. This script works because new window puts the focus on the newly created window and the focus will stay on that window until the script ends, another new window is executed or the script uses Select Window to put the focus on a different window.

          For years, I often use a simpler approach. I have the script switch layouts, perform find etc without opening a new window. I then have the script enter preview mode and pause. The user examines the previewed report and selects Print from the print menu if they decide to print out a copy. Pressing the enter key continues the script, which then returns the user to the original layout. (You can also put buttons on report layouts to return the user to their original layout and specify "hide when printing" to keep them from appearing when previewed/printed/pdf'd.)