Sub Report drill down
I have version 7.02 of the report writer and I have the following question.
I have a subreport that is a drill down. The drill down component is a
label. The drill down works fine. I was wondering if I can not print
the label when actually printing to a printer, pdf or whatever if the
subreport has not been expanded and print the label if the subreport has
been expanded.
I have a subreport that is a drill down. The drill down component is a
label. The drill down works fine. I was wondering if I can not print
the label when actually printing to a printer, pdf or whatever if the
subreport has not been expanded and print the label if the subreport has
been expanded.
This discussion has been closed.
Comments
Also is there a way to default the drill down to expanded
1. You might be able to keep track of which subreports are expanded using
the DrawCommandClick event of the drilldown component assigned. Then you
could set the visibile property of that component to False before the report
is sent to the printer or exported to PDF.
2. You can use the Subreport.ExpandAll to automatically expand all the
drilldowns in the report.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Take a look at the following example and article for help with this issue.
http://www.digital-metaphors.com/tips/drilldownsubreportmanualcontrol.zip
------------------------------------------------------------------
Tech Tip: How can I preview a fully expanded Drill-down Subreport
report and allow my users to selectively collapse subreports?
------------------------------------------------------------------
Problem: When a TppSubReport's ExpandAll property is set to True, the
DrillDownComponent is no longer "hot". This is because, as a performance
issue, it is faster to remove the drill-down functionality and reset the
report than it would be to create an unknown number of
TppDrillDownExpansions for all the subreport instances in the report.
Normally this is not a problem as, if you wish to collapse the drill-downs,
you can set ExpandAll to false, and the subreports will all collapse.
However, if you want to preview your report in an initially expanded state
and then allow the user to collapse certain subreports, a work-around is
needed...
We will be using Demo report #152 for this, so open dm0152.pas in
ReportBuilder's \Demos\1. Reports\ directory.
Add the following:
1. In the Uses clause, add ppTypes.
2. In the Private section of Tfrm0152 add:
FSubreportCount: Integer;
FExpansionComplete: Boolean;
3. Also in the Private section add:
procedure CreateExpansions(aCount: Integer);
4. For the implementation of this new method add the following:
procedure Tfrm0152.CreateExpansions(aCount: Integer);
var
liCounter: Integer;
begin
for liCounter := 0 to aCount - 1 do
begin
ppOrderDetailSubReport1.AddExpansion(liCounter);
end;
end;
5. Initialize your private fields in ppOrderDetail's BeforePrint event:
FSubreportCount := 0;
FExpansionComplete := False;
6. Add this line to ppOrderDetailSubreport1's OnPrint event:
if not ((ppOrderDetailSubreport1.Overflow) and (FExpansionComplete)) then
Inc(FSubreportCount);
7. Set ppOrderDetail's PassSetting property to psTwoPass.
8. Add the following to ppOrderDetail's OnEndFirstPass event handler:
if not FExpansionComplete then
begin
CreateExpansions(FSubreportCount);
ppOrderDetail.ResetFromPageNo(1);
ppOrderDetail.PassSetting := psOnePass;
FExpansionComplete := True;
end;
Basically we make the report a two-pass report, using the first pass to
count the number of subreports. When we finish the first pass, we add an
Expansion for each of the subreports - this has the effect of simulating
that the user has clicked all of the collapsed subreports, thereby expanding
them, but leaving them all "hot". The report is now displayed as fully
expanded, and the user can click subreports to collapse them.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com