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

Modify and create field

edited November 2002 in DADE
Hi,

Is there a method to update report if DB change. I would create a new field
(because a new field was created in the DB) or modify the properties of a
field (because the field in my DB was changed)...

do you have a little exemple.zip to this?

Thanks

Comments

  • edited November 2002
    You could create the report entirely on the fly based on the dataset it is
    connected to.

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


    That is a lot of overhead. One alternative is to create the layout by hand
    based on any new database changes. Another alternative is based on the fact
    that you want to change a datafield, for a DBText because you changed the
    data definition in the dataset and the datapipeline has a new field that it
    can bring to the report. Loop through the report objects, looking for
    components which as data aware by checking .IsDataAware function on each
    report component. Typecast to a TppComponent. When you find one, then check
    its Datafield property value as a TppDBText to see if it matches the field
    that you want to change the value of to a new one. Once you change it you
    are done and the report can be printed. If you are loading templates, then
    use the Report.Template.OnLoadEnd event to loop throug the report before it
    is shown in the run time designer or before it is printed.


    ----------------------------------------------
    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;

    --
    Tech Support mailto:support@digital-metaphors.com
    Digital Metaphors http://www.digital-metaphors.com




    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.