Modifiying SubReport at Run-Time
Delphi 7 and RB10. I have a report that consists of 8 different
subreports. I am trying to modify those at runtime, specifically not
hiding headers, details and footers based on the data. I know I can do
that by setting the visible property to False.
I'm not sure how to describe my problem. The elements are not defined so
I get compiler errors undeclared identifier. My code looks like this:
TfrmReportServiceCoordinator = class(TfrmBasicReport)
dsSC4: TDataSource;
dsSC7: TDataSource;
rptSC4: TppSubReport;
rptSC4Child: TppChildReport;
rptSC4Title3: TppLabel;
rptSC7: TppSubReport;
rptSC7Child: TppChildReport;
rptSC7Date: TppSystemVariable;
rptSC7Detail: TppDetailBand;
rptSC7Footer: TppFooterBand;
rptSC7Group: TppGroup;
rptSC7GroupFooter: TppGroupFooterBand;
rptSC7GroupFooterLine1: TppLine;
rptSC7GroupFooterLine2: TppLine;
rptSC7GroupFooterLine3: TppLine;
rptSC7GroupFooterLine4: TppLine;
rptSC7GroupHeader: TppGroupHeaderBand;
rptSC7Header: TppHeaderBand;
rptSC7HeaderLine1: TppLine;
rptSC7HeaderLine2: TppLine;
rptSC7Page: TppSystemVariable;
rptSC7Summary: TppSummaryBand;
rptSC7SummaryLine1: TppLine;
rptSC7SummaryLine2: TppLine;
rptSC7SummaryLine3: TppLine;
rptSC7SummaryLine4: TppLine;
rptSC7Title2: TppLabel;
rptSC7Title3: TppLabel;
When I open the report, there is a TppDetailBand object named
rptSC4Detail. Its just not in the list of objects so I cannot do
rptSC4Detail.Visible := False. Many of the other elements of that
subreport are not in the list either. Just those I listed above. I
looked at the DFM and the objects are in the DFM, just not in PAS file.
When I don't try to hide those objects, the report works just fine. I'm
stumped. Thanks in advance for the help.
Luke Miller
ResCorSoft, Inc.
subreports. I am trying to modify those at runtime, specifically not
hiding headers, details and footers based on the data. I know I can do
that by setting the visible property to False.
I'm not sure how to describe my problem. The elements are not defined so
I get compiler errors undeclared identifier. My code looks like this:
TfrmReportServiceCoordinator = class(TfrmBasicReport)
dsSC4: TDataSource;
dsSC7: TDataSource;
rptSC4: TppSubReport;
rptSC4Child: TppChildReport;
rptSC4Title3: TppLabel;
rptSC7: TppSubReport;
rptSC7Child: TppChildReport;
rptSC7Date: TppSystemVariable;
rptSC7Detail: TppDetailBand;
rptSC7Footer: TppFooterBand;
rptSC7Group: TppGroup;
rptSC7GroupFooter: TppGroupFooterBand;
rptSC7GroupFooterLine1: TppLine;
rptSC7GroupFooterLine2: TppLine;
rptSC7GroupFooterLine3: TppLine;
rptSC7GroupFooterLine4: TppLine;
rptSC7GroupHeader: TppGroupHeaderBand;
rptSC7Header: TppHeaderBand;
rptSC7HeaderLine1: TppLine;
rptSC7HeaderLine2: TppLine;
rptSC7Page: TppSystemVariable;
rptSC7Summary: TppSummaryBand;
rptSC7SummaryLine1: TppLine;
rptSC7SummaryLine2: TppLine;
rptSC7SummaryLine3: TppLine;
rptSC7SummaryLine4: TppLine;
rptSC7Title2: TppLabel;
rptSC7Title3: TppLabel;
When I open the report, there is a TppDetailBand object named
rptSC4Detail. Its just not in the list of objects so I cannot do
rptSC4Detail.Visible := False. Many of the other elements of that
subreport are not in the list either. Just those I listed above. I
looked at the DFM and the objects are in the DFM, just not in PAS file.
When I don't try to hide those objects, the report works just fine. I'm
stumped. Thanks in advance for the help.
Luke Miller
ResCorSoft, Inc.
This discussion has been closed.
Comments
RB10.
I'm unsure why some of these components were not defined when the report was
created. First note that if you are using Child style subreports, the
header and footer bands are not supported. The Detail, Title, and Summary
bands should be present however. Are you loading templates? Are you
certain these subreports are not being created in code or perhaps the
components are defined in the ancestor?
If you create a new report from scratch do the subreport components get
defined? One option would be to access the bands using the
Report.DetailBand, Report.HeaderBand, etc. properties. (In your case it
would be Subreport.Report.DetailBand).
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
print behavior is pbSection.I am not loading templates. The subreports
are not being created in code nor are the components defined in the
ancestor. Adding a field (ppDBText) to one of the subreports shows up in
the PAS file.
What I am missing are the definition of group headers, group footers and
individual in the PAS file. If I manually add the line: "rptSC4Detail:
TppDetailBand;" under "TfrmReportServiceCoordinator =
class(TfrmBasicReport)" I can then write the code rptSC4Detail.Visible
:= False or rptSC4Detail.Visible := True; and it is hidden or displayed
as needed.
The bottom line is that not every report object in the DFM got defined
in the PAS file.I don't know why. Do you have a tool that parses the DFM
and adds in the missing objects to the PAS file? Or at least a tool that
checks the DFM against the PAS file?
Also, I thought I read somewhere that RB10 has a new format as compared
to RB7. Do I just need to go through and open each report and save it
back to make sure everything is converted?
Thanks.
Luke Miller
If you create a new report from scratch do the subreport components get
defined?
The format differences between RB7 and RB10 simply deal with the added
features (properties not present in RB7). This will not in any way effect
your source. Were these components somehow defined before then dissapeared
when you upgraded? How were you accessing these components before?
One option would be to access the bands using the Report.DetailBand,
Report.HeaderBand, etc. properties. (In your case it would be
Subreport.Report.DetailBand). Another easy way to access the bands is by
using the Report.Bands property. The TComponent.FindComponent routine would
be another way to gain access to a subreport or band.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Went back several years in version control and those components never
were defined in PAS file. So the upgrade is not the culprit. This is the
first time I tried to access those objects programatically. Displaying
better messages when there were rows meeting the criteria is one of the
features I'm adding to this release. I think the best workaround is
manually adding to components to the PAS file. In that way my code is
consistent.
Though the workaround works, my concern is the integrity of my reports.
Obviously it's disturbing that those objects are missing from the PAS
file and I don't have time to go around checking every time I make a
change to a report. Nor do I have time to manually check 50-75 reports
with scores of objects to see if all of the fields are defined in the
PAS file. That's why a program to check the DFM against the PAS file
would be great.
Luke
Unfortunately we do not know of any tools that will parse and syncronize the
Delphi dfm and pas files. After a quick search through some of the Borland
newsgroups it seems most people are using the TParser class to do it on
their own.
One post mentioned the following product to get a list of objects defined in
your dfm. This could make it easier to detect which components need to be
added to your pas files.
http://www.peganza.com/#PAL
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks. I really don't have time to write my parser. Nor do I have time
to manually compare the outputs from peganza. I will suggest that there
is a problem/bug with RB.
Luke
This is not a known issue/bug with ReportBuilder nor am I able to recreate
it here on my machine(s). Are you able to recreate this behavior with the
latest version of ReportBuilder? If so, please provide me with the exact
steps I need to take to recreate it here on my machine.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Unfortunately, I can't recreate. I can only know that I have a report(s)
with that problem.
Luke