Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Wrong report loaded

edited November 2007 in General
Hello.

I have a simple application with three TppReport objects on my mainform;
Report1, Report2, Report3
If I try to print/preview Report2 after having printed/previewed Report3, it
seems that Report3 is the one that is loaded.
When debuging, there is no doubt that the Report2 object is printed/called.
I can not verify that it is Report3 that is loaded, because I get AV in the
query assosiated with Report3.

Any Idea?

Thanks
Petter Topp
D 2007, RB 10 Ent.

Comments

  • edited November 2007
    Hi Petter,

    How are you printing these reports? Are you able to recreate this issue by
    simply placing three reports on a form along with three buttons, each
    calling Report.Print for their corresponding report? In my quick testing,
    this worked as expected.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2007
    Hello Nico.

    I have not had any problems with this before, so I don't think that this can
    be reproduced...

    The reports are based on a separate query using DBPipeline and aDbisam
    queries.

    if frmRapportVelger.cxRadioGroup1.ItemIndex = 0 then begin
    if ReportPreview then begin
    rpFraktBrev.DeviceType:= 'Screen';
    rpFraktBrev.Print;
    end
    else begin
    rpFraktBrev.DeviceType:= 'Printer';
    rpFraktBrev.Print;
    end;
    end;
    if frmRapportVelger.cxRadioGroup1.ItemIndex = 1 then begin
    if ReportPreview then begin
    rpFakturaGrunnlag.DeviceType:= 'Screen';
    rpFakturaGrunnlag.Print;
    //THIS IS WHERE THE EXCEPTION SHOWS, TELLING ME THAT A FIELD IN THE QUERY
    BELONGING TO THE REPORT BELOW,
    //DOES NOT EXIST. THERE ARE NO WAY THAT THE ASSOSIATED OBJECTS COULD BE
    MIXED UP, NAMES ARE COMPLETELY DIFFERENT.
    end
    else begin
    rpFakturaGrunnlag.DeviceType:= 'Printer';
    rpFakturaGrunnlag.Print;
    end;
    Invoice;
    end;
    if frmRapportVelger.cxRadioGroup1.ItemIndex = 2 then begin
    if ReportPreview then begin
    rpAvviksRap.DeviceType:= 'Screen';
    rpAvviksRap.Print;
    end
    else begin
    rpAvviksRap.DeviceType:= 'Printer';
    rpAvviksRap.Print;
    end;
    end;


    There have been some problems with this app. bringing it from D7 to Delphi
    2007, at some point I lost some components (TIdFTP and some XML objects) on
    the form...
    I was also having some problems when trying to copy one of the TppReport
    objects (AV).
    It could be some issues with the dfm file, but I don't know where to look.

    Regards
    Petter




  • edited November 2007
    Hello Nico.

    I have solved the issue, but this is realy a workaround...

    I have dropped a new TppReport on my form, and copied the contents of my
    original report.
    Then the reports have been renamed so that the new report has the same name
    as the original.

    Now things work as supposed...

    I have experienced problems with copying whole report object earlier, and
    don't dare doing this any more.
    If I should set up a new report who is very similar to an existing report,
    how should I go about it?

    Thanks
    Petter


    "Petter Topp" skrev i melding
  • edited November 2007
    Hi Petter,

    We have not seen anything like this in the past. The fact that recreating
    the report solved the problem leads me to believe that you perhaps had a
    corrupt template (report definition). When dealing with complex reports you
    might find it is best to recreate them from scratch if you need to copy
    them. It usually will not take as much time as you think and will give you
    a chance to refactor the original design.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2007

    To manage resources more efficiently, a better design is to have only one
    TppReport per form/datatmodule. Create the report form/datamodule instance
    when a request to preview/print is made and afterwards free the
    form/datamodule. For an example see RBuilder\Demos\Reports\Demo.dpr - this
    project contains over 100 hundred reports. The application tutorials in the
    Developers Guide contains a tutorial on how to create a similar application.

    If you are loading reports from .rtm files or a database and you have more
    than one TppReport instance per form/datamodule, then naming collisions can
    occur when the report is loaded. In Delphi all components with a common
    Owner (i.e. the Form/DataModule) must have a unique name.





    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2007
    Hello Nico.

    In this application I don't see the need for loading templates from either
    file or database, it's a very simple solution.
    So if the reports aren't saved as templates, where are the reports inside a
    TppReport stored?
    Could this file be recreated?

    Thanks
    Petter


  • edited November 2007
    If you perform a View as Text on the Delphi Form/DataModule, you will see
    the report definition there. It is a composite object structure
    Report.Bands[ ].Objects[ ]

    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2007
    Also make sure you have TppReport.SaveAsTemplate set to False.

    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.