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 :
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
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
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
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.
Thanks for the suggestion, unfortunately, it does not work. Even setting it before calling rep.ShowReport does not work.
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.