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

Help - Control number of bands in the DetailBand

edited July 2004 in General
I'm having a problem controlling the number of bands in a DetailBand as
determined by an if-then condition. I want the detail band to list
certain fields for all records in the first band and another set of
fields in the second band for records that meet the if-then condition.

I have used the BeforePrint event, 2 regions in the Detailband with
selected fields in each region and toggling their visibility properties
in accordance with the if-then condition. When I test the code, I find
the number of lines printed is controlled only by the last record. For
example, assume there are 3 records with the second meeting the if-then
condition which should print 2 lines. The first and last record
should have only one line. The report prints with only 1 line for all
3. If the last record meets the condition, all 3 records print with 2
bands. How can I control the number of bands for each individual record?

I appreciate your help!

Gerry Tomlin
gktomlin@verizon.net

Comments

  • edited July 2004
    Hi Gerry,

    ReportBuilder does not traverse mutiple records in a single band. The
    detail band will only show one record from each field at a time, then
    traversing to the next record, another detail band will print with the next
    set of records. For instance, if you have the following simple table...

    Cyclist Team
    --------- ---------
    Lance Armstrong U.S Postal
    Jan Ulrich T-Mobile
    Tyler Hamilton Phonak
    Ivan Basso CSC

    If I place two TppDBText components inside my detail band pointing to the
    Cyclist and Team fields, my report will then display 4 detail bands, one for
    each row in my dataset...

    Header Band
    Detail Band: Lance Armstrong: U.S. Postal
    Detail Band: Jan Ulirch: T-Mobile
    Detail Band: Tyler Hamilton: Phonak
    Detail Band: Ivan Basso: CSC
    FooterBand

    If you would like to traverse some fields completely and display them
    separate from other "filtered" fields, I would strongly suggest creating
    multiple datasets and connecting multiple datapipelines to your report using
    subreports. See the article below for more information on how to connect
    multiple datasets to a report and on how ReportBuilder traverses data.

    ------------------------------------------------
    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
    Thanks, Nico,

    Let me clarify what I am trying to do. In your example below assume
    that there is a third field (Boolean) called "Top Ten" meaning they are
    or are not in the top ten in the race. Further assume that only Lance
    Armstrong has True in this field. The rest have False. Now, what I
    want to do is print the same report as you did below, with the exception
    that there is a second band in the DetalBand if "Top Ten" is True.
    Thus, the DetailBand would have 2 bands for the Lance Armstrong record,
    the first as in your example and the second band showing the text 'Top
    Ten'. The other 3 would have only 1 band as in your example. I've had
    the report like your example working for months, but the customer wants
    the modification I have described.

    Thanks!
    Gerry Tomlin
    gktomlin@verizon.net


  • edited July 2004
    Hi Gerry,

    So if I understand you correctly, you would like your report to look like
    the following...

    Header Band: ALL Cyclists
    Detail Band: Lance Armstrong: U.S. Postal
    Detail Band: Jan Ulirch: T-Mobile
    Detail Band: Tyler Hamilton: Phonak
    Detail Band: Ivan Basso: CSC
    FooterBand: ALL Cyclists End

    Header Band: TOP TEN Cyclists
    DetailBand: LanceArmstrong: U.S. Postal
    Footer Band: TOP TEN Cyclists

    As I mentioned below, the easiest way to accomplish this would be to create
    two separate datasets, one that contains all the information and one for the
    filtered information. Then simply connect the first dataset to the main
    report and traverse all the data in the detail band of the main report, and
    place a TppSubreport somewhere below the detail band and connect it to the
    second dataset. In its detail band traverse the filtered data. It may be
    possible to link the same dataset to both the main report and the subreport
    but you will either need to edit the search criteria usign AutoSearch for
    the subreport or try to code something to remove the records from view that
    you do not want to see (definitely not recomended). If the above format is
    correct, I can create a small example for you to use as a reference if you
    would like. Let me know.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Nico Cizik (Digital Metaphors) wrote:
    ThanksNico,

    Not quite. What I want the report to look like is the following:

    Header Band: ALL Cyclists
    Detail Band: Lance Armstrong: U.S. Postal
    Detail band: In the TOP TEN
    Detail Band: Jan Ulirch: T-Mobile
    Detail Band: Tyler Hamilton: Phonak
    Detail Band: Ivan Basso: CSC
    FooterBand: ALL Cyclists End

    I could do it as you have shown, but the customer wants it as I have
    shown. Is it possible to do it the customer's way?

    Gerry Tomlin
    gktomlin@verizon.net
  • edited July 2004
    Hi Gerry,

    Ok, now I think I understand :). I went ahead and created a small example
    for you that does what I think you want. Hope it helps.

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

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Thanks so very much for all your help, Nico!

    Unfortunately, I cannot compile your .pas file apparantly because I am
    using Delphi 5 with ReportBuilder Pro 6.x. It appears you are using
    some properties in Delphi 7 that I do not have in Delphi 5. I assume
    this can be done in Delphi 5.

    I have toggled a region's visibility as you did in the BeforePrint
    event, however, it still prints according to the if-then condition of
    ONLY the last record. This is the same problem I have had for the last
    week or more. Do you have any more suggestions? Sorry to be such a pain!

    Gerry Tomlin
    gktomlin@verizon.net

  • edited July 2004
    Hi Gerry,

    You should be able to simply ignore the new properties to run the example
    successfully. There have been hundreds of bug fixes and enhancements since
    ReportBuilder 6. As a test, try downloading a trial version of
    ReportBuilder 7.04 and test the example with that to see if this is the
    effect you are after. Be sure you back up any template files you try to
    load in the new version of ReportBuilder.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2004
    Thank you so very much for all your help, Nico!!!

    I finally got it to work the way I wanted!! The KEY to success was
    using the following condition referring to the DataPipeline as you did
    in your example:

    if pGCSalesReport.DetailBand.DataPipeline['Sale_Price'] =
    ppGCSalesReport.DetailBand.DataPipeline['Unit_Price'] then

    I had previously (and apparantly erronously) referred to the DataSet.

    You have been great in helping me and I appreciate it. By the way, I am
    still using D5 and RB 6.x with all of your patches downloaded.

    Gerry Tomlin
    gktomlin@verizon.net

This discussion has been closed.