One report, two designs

Hello,

I have an invoice report and the client now wants two designs, depending on the company creating the invoice.
I have duplicated my page1, changed the design in Page2 and added this :
procedure repOnStartReport(Sender: TfrxComponent);
begin
  Page1.visible := <qDO."company"> <> 1;
  Page2.visible := <qDO."company"> = 1;
end;

Unfortunately, for company 1 (page 2), only the ReportSummary is printed, not the MasterData or DetailData.

How should I proceed ?

Thanks for your help,

JC

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 9:10AM
    without seeing your .fr3file itI can't tell what you are trying to do.
    I assume <qDO."company"> is a field in the master dataset.
    what happens is when the page is not visible the mdband still runs through all the data till the end of the dataset.
    so you have no data for the second design page.
    when using multiple design pages you need to connect the
    tfrxreport component to a dataset(NOT the same as the master) to tell the report the number of times to run
  • gpigpi
    edited 9:10AM
    Try to set page's visiblity in main procedure of script
  • edited 9:10AM
    I would just create 2 reports.
    Putting it into one report will become more and more complex when even more companies have to be catered for.
    One thing one can count on is that every company will have their own quirks you have to cater for.

    The most critical aspect in design is not the design itself but the maintenance thereafter.
    IMO, simplicity, which leads to one being able to still understand the code after not working on it for 6 months is the key.
  • edited 9:10AM
    gpi wrote: »
    Try to set page's visiblity in main procedure of script

    Thanks for the suggestion, unfortunately, it does not work. Even setting it before calling rep.ShowReport does not work.
  • edited 9:10AM
    gordk wrote: »
    when using multiple design pages you need to connect the
    tfrxreport component to a dataset(NOT the same as the master) to tell the report the number of times to run
    I didn't know what dataset to link the report to. And what "number of times to run". 2 in my case ?
    gordk wrote: »
    I would just create 2 reports.
    Putting it into one report will become more and more complex when even more companies have to be catered for.
    I did not express myself correctly : the 2 companies are part of the same big company. They just have "presentation" differences.
    I don't want to create 2 reports because most of the logic part is in the report's code and duplicating this would create maintenance problems (forgetting a change in one of the versions).

    To solve my problem, I used 2 subreports for each part : 2 for MasterData, 2 for DetailData and 2 for ReportSummary. That way, I am quite free in the design (it's possible to add child bands if necessary) while sharing all the code between the 2 designs.

    A few tips :
    - in every subreport, add a masterdata band, not attached to any dataset and a number of records = 1
    - in order to see all the subreports in the main report (they are positionned one on top of the other), I give them different vertical sizes and place the taller one at the bottom
    - to make every subreport responsible for its visibility : on the main report, define the subreports' OnBeforePrint with something like "subrep1.Visible:=somecondition = 1;"

    Thanks everyone for your help.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.