4 Replies Latest reply on Nov 16, 2011 8:08 PM by PeterDowns

    Report Printing Issue

    PeterDowns

      Title

      Report Printing Issue

      Post

      Hi

      Have a report that is pulling data from a number of portals on tabs on a layout.  I have set up a script that prints the required records from each portal seperately so there are about 4 x print requests (there are 4 x record layouts). It works well except if one of the portals have no data / records in it.

      What happens then is that instead of printing nothing or a blank layout it prints the actual screen layouts for every record and in colour!!. Which can be an issue with 100+ records.

      Here is my script for the printing

      Cheers

      Downsy

      Screen_Shot_2011-11-04_at_10.17.18_AM.png

        • 1. Re: Report Printing Issue
          LaRetta_1

          You need to error test that Go To Related Records[] to be sure there are related records before going there.  There have been discussions about GTRR being untrustworthy but that is simply not so.  It is just important to understand how the errors are trapped when using it so here is the concept:

          If you want to go to related records matching current parent record only, check for error 101.  This will mean there are no related records.

          If you want to find all related records matching the current found set of parents, then error 101 is useless because you will get it ONLY when the parent record you are currently on doesn't have children.  So when testing GTRR with 'found set' instead of 'current record', test for 401 which would mean NONE of the parent records have children.

          All of your GTRRs are 'current record' only so trapping for 101 will work.  An error means the new window will not be created nor will the layout switch take place and that is why it prints the wrong layouts.

          • 2. Re: Report Printing Issue
            PeterDowns

            Hi LaRetta,

            thanks for the advice. I applied Error Capture to the script see below.

            It seems to work well and halt the script except it closes the database. (It was doing this before as well so it is not a new thing). Any ideas, it prints out the report and closes File Maker. If there are records available it doesn't close.

            Cheers

            • 3. Re: Report Printing Issue
              LaRetta_1

              If you have only one window open and issue a Close Window[] then it will close the file and I believe that is what is happening.  I am not sure why you are using the Else If[] ...  Either there is an error or there is not an error so it would be IF ... ELSE 

              If [ error ]
              .... do this
              Else
              .... do this
              End If

              But main problem is you are testing for the error before you perform the GTRR:

              Set Error Capture [ On ]
              If [ Get ( LastError ... but nothing has happend that it should trap.

              Consider not moving to another layout unless there are related records:

              Set Error Capture [ On ]
              Go To Related Record [ Related Records Only ; Project_RelatedTasks ; using Rpt_Budget_Actuals ; New Window ]
              If [ NOT Get ( LastError ) // there are related records ]
              ... preview
              ... print
              ... browse mode
              ... close window
              ............. you are now still on the original layout and on the same record

              End If
              Set Error Capture [ On ]
              Go To Related Record [ Related Records Only ; Project_RelatedAssignments ; using Rpt_ProjectPersonnel ; New Window ]
              If [ NOT Get ( LastError ) // there are related records ]
              ... preview
              ... print
              ... browse mode
              ... close window
              ............. you are now still on the original layout and on the same record

              End If

              This type of construct will allow for individual sorts in each 'report' generated or other specifics to each report.  And in fact, sometimes it helps to have the preview, print, browse and close window in ONE external script and run it as sub-script;  I cannot say here - just a consideration.  And if those reports can ever be generated individually, sometimes it works best to write as separate scripts and run it all as series of sub-scripts.

              • 4. Re: Report Printing Issue
                PeterDowns

                Thanks,

                worked a treat. I will split it up into subscripts.

                Cheers

                Downsy