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

Not sure how to handle this

edited July 2004 in General
(SQL2K, D7, RB 7.04)

I have two queries (lets call them q1 and q2).
There is a one to many relationship between q1 and q2 (many q2's for each
q1).
q1 contains text data that I have built a report for - working fine.
q2 contains paths to tiff images that I need to print also.
I want 1 tiff per page and I also need some of the text data from the
matching q1 to be printed too so I can match up the images with the q1
report.

I must be missing something!

try
rpTags1.Print; //does the q1 data
rpImages.Print; //prints the same tiff image 'x' number of
times
finally
end;

procedure TFormOutput.rpImagesBeforePrint(Sender: TObject);
var fn: string;
begin
fn := q2.FieldByName('Filename').AsString;
ppImage1.Picture.LoadFromFile(fn);
end;

Comments

  • edited July 2004
    Hi Sydney,

    From your code below, it looks like you have two report objects that you are
    printing one after the other? This will not combine the pages or give you
    the output you are after. I would suggest combining everything into one
    report object. If you need to connect to a separate datset, you can use
    subreports inside the main report. Let me know exactly what you would like
    your report to look like and we can go from there. Thanks.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Thanks Nico.
    Since all the Tiffs are full 8x11" in size, I want them to be printed on a
    separate page. That's why I thought it would be easier to use two report
    objects. But if you think subreports is the way to go, then lets workpu
    that scenario. Here's what I want to see: see attached word doc or
    download from www.wedodata.com/download/xfer/reportsample.zip



  • edited July 2004
    Hi Sydney,

    I would suggest creating a Master Detail report based on the two queries you
    currently have. See the article below on the fundamentals on creating a
    Mastre Detail report. Also, I created a small example that shows a report
    similar to the one you described. Hope this helps.

    http://www.digital-metaphors.com/tips/SLotterby.zip

    ------------------------------------------------
    TECH TIP: Fundamentals of Report Data Traversal
    ------------------------------------------------


    1. Single Table Listing Report

    Assign the Report.DataPipeline property and leave the DetailBand.Pipeline
    unassigned.

    The report will traverse the data from start to end (based on the
    datapipeline range settings and honoring any filters you've placed on the
    datset etc.)


    2. Master/Detail Report:

    A. Assign the Report.DataPipeline property to the master. Create a subreport
    in the detail band and assign the childreport.DataPipeline to the detail
    datapipeline.

    Use either the visual linking features available from the Report Designer's
    Data tab, or Use standard Delphi dataset linking to define the relationships
    between the datasets.

    The Report will traverse the master records and for each, the subreport will
    traverse the detail data related to the master.


    3. Master with 2 Details

    Configure as in 2 above. Add an additional subreport to the detailband. Set
    subreport.ShiftRelativeTo property to the point to the first subreport.
    Connect the ChildReport's DataPipeline to the detail data.


    4. Report connected to no datapipelines.

    When Report.AutoStop is set to True, the Report will print a single detail
    band.

    When Report.AutoStop is set to False, the Report will print detail bands
    until instructed
    to stop. You can control when the report stops by setting the
    Report.PageLimit property or by calling Report.DataTraversalCompleted
    method. Otherwise the report will never stop.


    Additional Notes:
    ----------------

    1. SubReports have a Report property that is of type TppChildReport. Thus,
    programmatically you can code SubReport.Report.DataPipeline :=
    myDataPipeline.

    2. ChildReport's traverse data following the same rules as above. A
    ChildReport prints in its entirety each time it gets a turn to print.

    3. For a Child style SubReport use the Title/Summary band rather than the
    Header/Footer (or use a GroupHeader/GroupFooter combo). A standard
    Header/Footer will not work because these always print at the very
    top/bottom of the page.

    4. Do not filter the dataset of modify it any way once the report.Print
    command is issued. If you need to do master/detail and cannot use
    linked datasets, then use the master DataPipeline.OnRecordPositionChange
    event to filter the detail dataset.

    5. The reports and datapipelines use dataset bookmarking. Make sure
    the dataset can support bi-directional navigation.



    Check out the RBuilder\Demos\Reports\Demo.dpr project. Reports 0071, 0072,
    0073 show examples of master w/mutliple detail style reports. Number 0072
    has two detail reports.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Nico,
    Thanks for sample and the tips. However, my app is different conceptually.
    Let me use your sample as an example.
    Imagine for each Biolife Master rec actually had four different images for
    each fish (left, right, up, down views) instead of just one image per master
    record. And that each of the four fish images were of such a size that they
    needed to take up a full page (8x11"). Furthermore, because each of the
    images would take up full pages, you would not want to waste space and have
    just a single page for the text details for each fish that comes from
    Master. Instead, you want to print as many Master record text details per
    page as possible. In order for the reader of the physical report to "link"
    the fish images (one per page from the Detail query) with the text details
    (many per page from the Master query) each fish image would need to have the
    "Species No" printed as a header on the page.

    In this scenario, don't I need two TppReport objects and abandon the
    sub-report approach? The first TppReport object would traverse the Master
    and print the text details for each "Species No" - as many as would fit per
    page. Then, in the AfterScroll event for Master, you would execute a query
    to pull all four fish images for the current Master.Species No and execute
    the second TppReport object from within the AfterScroll event.

    Given the above scenario, is my suggestion the best/only way to do this or
    am I still missing something?

  • edited July 2004
    Hi Sydney,

    master

    This is exactly what a Master-Detail report is supposed to handle. My
    example only showed one image per master record because only one was
    available. When you link two queries in a Master-Detail relationship,
    ReportBuilder will traverse the detail dataset as long as the linking field
    is the same. If there were four images for the first species, ReportBuilder
    would have printed all four images. You may need to play around with the
    formatting but I think this would work best for your needs.

    Using two TppReport objects will require that you create two completely
    separate print jobs that will occur at separate times. It is not possible
    to print two reports simultaneously.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Nico,
    I'm still not communicating my problem. Please pardon the CAPS below - I'm
    not shouting - just need to emphasize some things.

    Your master/detail example prints master-text details followed by image(s).
    So your sample prints Species No 90020 text details followed by the Fish
    Image/Images for 90020 ON THE SAME PAGE. In your case 90030 image appears
    on page2, 90050 on page3 etc. Details for each Species No is followed by
    the image(s) for that same Species No.

    Imagine your sample report WITHOUT the images. That's what I want to see
    on the first report. The second report would contain only the images for
    each Species No at one per page.

    I realize that this means I will have two separate print jobs and won't see
    #2 until #1 is finished (if I am Previewing).
    I know this is NOT the typical way of doing things but I really do have a
    special need that would take way too long to justify to you. So, I don't
    see a way around it given that I definitely need the reporting to happen the
    way I have described.

  • edited July 2004
    Hi Sydney,

    Thanks for the clarification. I don't mean to force my methods on you, it
    would definitely be possible to accomplish what you described below using
    two separate TppReport objects and two separate print jobs. However, as an
    alternative, you could possibly create one report, the main report looking
    exactly like your first report, then place a Section Style Subreport in the
    Summary band containing all the images. This will give you the same effect
    as printing two separate reports only using one report object (less
    memory/resource usage etc.) Hope this helps.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Thanks. I'll play with both methods and get back if needed.

  • edited July 2004
    Nico,
    I am trying to follow your Section Style Subreport recommendation. I have
    created a Subreport in the Summary band but don't know how to specify it is
    a Section Style Subreport. Could you do me a favor and modify your Fish
    sample to report the way you are suggesting so I can follow more clearly?
    i.e. the Fish report would show all the text for all fish first followed by
    all the fish images at one per page.

    This would really help.

    tia


  • edited August 2004
    Hi Sydney,

    Here you go. With this method, there is no need to link the datasets any
    more.

    You can change the style of a subreport by right clicking over the subreport
    object and selecting Child, Fixed, or Section.

    http://www.digital-metaphors.com/tips/SLotterby.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.