Home Subreports

Dynamically Loading Subreports to minimize maintenance

edited February 2003 in Subreports
I am using Delphi 5 and ReportBuilder 6.03.

PREFACE

(1) I have a need to dynamically load subreports. I have read earlier
threads that refer to one of the demos that illustrates dynamically loading
subreports; however, I cannot find it in the demos that are included with
ReportBuilder 6.03.

(2) In addition to needing to know how to dynamically load subreports, I
would like to know if what I am trying to do is possible.

PROBLEM

I have an application where I have a letter with multiple addendums. Each
addendum is a subreport in the header section of the letter.

Many of these subreports have code which executes in the OnPrint event of
the subreport component which changes the presentation of controls that
exist in the respective subreport. Also, some of the subreports have code in
the BeforePrint events of their detail sections.

In addition to the Letter and Addendums report described above, I have each
of the Addendums as an individual report.

My experience is that if I create a report. Then, load that report as a
subreport in the report designer, then the component names change. Since I
am changing the presentation of some of the subreports via the components of
the subreports, each component must be uniquely named. Therefore, the code
for each subreport must be unique with respect to the component name.
Therefore, it is necessary to effectively have two sets of code due to the
unique component names within the subreport and it's standalone duplicate
report..

Now, my client (i.e., customer) wants another Letter and Addendum report
created to include additional addendums. So, I am beginning to have a
maintenance problem that I want to resolve - that is, I will now be dealing
with three duplicate sets of reports that each contain uniquely named
components which are acted upon in code.

MY PROPOSED SOLUTION: It seems that if I have one unique report for each
addendum, that I can use that report individually or dynamically load it as
a subreport. Therefore, I would only have one set of reports and associated
code. I am assuming that if I dynamically load the subreports that the
component names will not be changed upon loading and therefore the code that
operates on those components will fire as designed.

QUESTIONS

(1) Is this solution feasible? Or am I overlooking something?

(2) Is there another way to avoid having duplicate sets of reports when
using subreports that require code to dynamically alter the presentation?

Comments

This discussion has been closed.