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

Two reports on one page, again

edited July 2018 in General
Hi,

I know this topic has been opened at least twice (one example is http://www.digital-metaphors.com/forums/discussion/comment/17345) and I am trying to implement this solution in my application but it does not work as expected.
I want to print 2 consecutive confirmations (records) on single A4 page from a list. List is stored in TClientDataSet connected via TDataSource to TppDBPipeLine. According to the mentioned topic I have created a RTM which has 2 subreports in Detail band, of fixed type, each has defined height 148,5 mm (half of the page size), whilst page has no top and bottom margin. Each subreport is connected to same dataset, ExpandAll = True, TraverseAllData = true. This will produce 2 copies of same record which is not what I need.
The only version that is close to desired is to have:
On Main - no datapipeline, in detail band one subreport
Subreport - datapipeline connected to the list, type pbChild, and in it Detail band of fixed height with the memo field and other elements adjusted so its height is close to 148,5 mm.
If I leave detail in subreport as dynamic height, then I get 3 or even 4 records on one page which is undesired.

What am I missing, which property I haven't set correctly? I am using Delphi Berlin with ReportBuilder 18.01.

Many thanks in advance. Best regards,
Goran
Goran Brumen
Audax d.o.o.

Comments

  • Hi Goran,

    To print two consecutive records per page, try placing a single (Fixed) subreport sized to half a page inside the detail band of the main report. This should reprint the subreport twice per page and properly traverse the records in your dataset as needed.

    Also, depending on if you need to travers data inside each subreport, you may need to create a master-detail data relationship with the main report and subreport(s).

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Hi Nico,
    thank You for Your answer but unfortunately it does not work. Neither of Your ideas. As first attempt I did like this:
    - Main: no pipeline, only Detail band visible, in it only one subreport with print behaviour pbFixed of 148,5 mm height (1/2 of A4 length). Please note that margins top and bottom are set to 0.
    - SubReport1: pipeline set to my pipeline which has some indicators and few fields that need to be printed. TraverseAllData = True. In subreport I have 2 groups, in (inner) header band is the company data and few details regarding the patient, in detail band is DB memo field and below it a region with field connected to the doctor's name.
    This resulted 7 pages with the data for every patient on the list. Nice but waste of paper ;)

    For next attempt I assigned my list dataset's pipeline to Main, TraverseAllData=False on fixed subreport and this resulted 7 pages of data for first patient only.

    Next attempt was to establish Master-Detail. Master dataset was company's data so it had only one record, the detail is still the list of patient data as before. With subreport's TraverseAllData=True produced 7 pages with only 1 patient's data per page.

    I switched the Main's datapipeline (=master) to the list, subreport's pipeline remained the same and this produced 49 pages of patient's data. One every 5 pages appeared 2 subreports per page with data of last and first patient.

    I finally settled though not happy with changing the subreport type to pbSection. Removed master-detail relationship (main does not have any pipeline) and slight modifications in the bands of subreport and their contents. So in subreport I still have 2 groups, in header of the inner are company's data (as memo) and a region that follows it with patient data. Groups are always dynamic, they do not obey PrintHeight=phStatic in any case. Why not I don't know. In detail I moved the memo field into the region, after this region is region with field with doctor's name. Region with memo is way bigger than it should; if I set it for one line, it does not expand (although Stretch=true) but it can shrink from space for 10 lines to only 2. Detail's height is 80 mm, one groups is 0, the other 57 + about 10 with "BottomOffset's".
    This gives me approximately the desired result. It is not pretty but is works somehow. I had also an idea to rotate the page from portrait to landscape and rotate all the data for 90° but this does not work with the memo field (at least). Maybe for the future one would need some division break that will instruct RB to move next record on same page? This might do the trick with fixed subreports.

    Thank You again and best regards,
    Goran
    Goran Brumen
    Audax d.o.o.
  • Hi Goran,

    Your third attempt is where we need to focus :smile: Master-Detail with a single fixed style subreport.

    My guess is that the fixed subreport height needs to be reduced to fit two on a single page. I suggest experimenting with the subreport height to see if you can get two to fit on a single page. Also note that most printers cannot handle 0 margins.

    Best Regards,

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

    I played with this report a bit but fixed section simply does not work. For updated third attempt, I have done as follows.
    Master dataset is dataset with one record only and has only data of the company.
    Detail dataset has 7 records with some patient data and some text.

    Page is A4, magins set to 10 mm all around. Printer is HP LaserJet. On main is one subreport, set with print behavior as pbFixed, ExpandAll = False, KeepTogether=True, NewPrintJob=False, TraverseAllData=True, MinHeight = 0, Height = 76 mm.

    Subreport has 3 groups, first is connected to ID of master dataset, then the next two are two ID's from the detail dataset with the second patient ID. In header of patient ID is memo from Master dataset and basic patient data plus document name, PrintHeight is static, 48mm height. Detail band has print height Dynamic, ColumnBalancing=off, ColumnTraversal Top to bottom, no backgrounds. It has only memo field and region with DBText (doctor's name).

    The result is one patient per page, 7 pages. And this data occupies a bit les than 1/3 of a page. Just changing the section from pbFixed to pbSection produces 3 consecutive confirmations on single page, all together 3 pages (due to 7 records). Changing the height, minimum height and even BottomOffset on subreport (on Main) does not have any effect (which is a pitty).

    I am lacking of ideas now. For the time being I will revert back to my previous solution but I will happily test any additional idea from DM.

    Thank You and best regards,
    Goran
    Goran Brumen
    Audax d.o.o.
  • edited July 2018
    Hi Goran,

    It appears your report/data is much more complex than I originally thought. I feel that in order to achieve what you want, we need to start simple, then move to more complex iterations.

    I just sent a minimal example of using fixed style subreports (2 per page) to you. I suggest getting something similar working with your data first before adding in groups, columns, etc.


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
Sign In or Register to comment.