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

Change RTM datasource?

edited May 2004 in General
Hi!

I want to filter the result of a RTM than contains its own SQL sentence.
I use two TppReport components:
* ppReport1 prints a report based on a BDEPipeline. Its datasource is a
TTable (customers.db)
* ppReport2 loads a RTM file that contains a SQL query. The query of this
RTM file obtains data from customers.db (not always, each rtm file obtains
data from different tables)

I want to filter TTable1 component and, if it is filtered, then ppReport2
will print ONLY the filtered data. I can't do it because ppreport2 has its
own sql query.

I can change ppreport2 pipeline to obtain data from ppreport1 pipeline, and
if Table1 is filtered (40 records), it will print the same record 40 times,
because DBText components are still assigned to the SQL query.
How can I change the Datasource of the DBText componentes to retrieve data
from another Pipeline?
Have I to change one by one?

Thanks!

Comments

  • edited May 2004
    Hi Santy,

    There are two ways you could solve this issue.

    1. Extract the SQL object from the template and edit the search criteria so
    it matches the filter you set for the TTable on your form.

    2. Loop through each component on your report and if the component is data
    aware, change the data pipeline to use the one connected to your filtered
    table. Please see the article below on looping through all report
    components.

    ----------------------------------------------
    Tech Tip: Loop Thru All Objects in a Report
    ---------------------------------------------

    A ReportBuilder report is composed of a set
    of components. The basic structure is

    Reports.Bands[].Objects[]

    The bands and objects within the report can
    be accessed directly by object name or
    via the Bands and Objects array properties.

    Below is an example of using the Bands and
    Objects array properties to change the font for
    all objects on a report.


    uses
    ppClass;


    procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;

    begin

    for liBand := 0 to aReport.BandCount-1 do

    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    if lObject.HasFont then
    lObject.Font := aFont;

    end;

    end;


    --
    Best Regards,

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