memo problem
Hi,
Part 1:
I have a TppMemo component (let's call it MemoDesign) located in a group
footer band. I add (through code) the text from another DBMemo located in
the detail band, so that MemoDesign contains the text from all the records.
But when the MemoDesign gets too large for the first page, the text does not
continue on the next page. (The report has made a new page, but the text
doesn't show.)
How can I get the text from MemoDesign to continue on the next page?
Part 2:
Since I didn't get part 1 to work, I tried to create TppMemo components in
run time for every DBMemo-text. This way, I would get smaller memo
components that hopefully would break to the next page when there was no
more space on the first page.
(All the memo-components was added to a TList (MemoList) in order to control
the components.)
But I don't get the memo-components to show in my report (in the group
footer band). Maybe I get the Top and Left properties wrong?
(And how do I set the width in order to use almost all the page width?)
The new memo components should be shifting relative to the previous memo
component.
Roughly, my code in the DBMemoOnprint event looks like this:
Memo := TppMemo.Create(GroupFooterBand2);
Memo.Band := GroupFooterBand2;
Memo.Stretch := True;
Memo.Width := 100; { What should this be in order to use the page
width? }
if MemoList.Count = 0 then
begin
Memo.Left := 0; { Is this correct? }
Memo.Top := 0; { Is this correct? }
end
else begin
Memo.ShiftRelativeTo := TppMemo(MerknadListe.Last); { Can't I do
this? }
end;
Memo.Lines.Add(DBMemo.Lines.Text);
MemoList.Add(Memo);
Then I tried to set the ShiftRelativeTo property of the first created memo
component to the MemoDesign component (from part 1) which is still in the
report. This time the first memo component shows correctly, but still all
the other memo components are "missing".
I have spent hours trying to solve this problem. What am I doing wrong? Is
there a better solution to my problem (in part 1)?
TIA,
Jon-Egil Borch
Part 1:
I have a TppMemo component (let's call it MemoDesign) located in a group
footer band. I add (through code) the text from another DBMemo located in
the detail band, so that MemoDesign contains the text from all the records.
But when the MemoDesign gets too large for the first page, the text does not
continue on the next page. (The report has made a new page, but the text
doesn't show.)
How can I get the text from MemoDesign to continue on the next page?
Part 2:
Since I didn't get part 1 to work, I tried to create TppMemo components in
run time for every DBMemo-text. This way, I would get smaller memo
components that hopefully would break to the next page when there was no
more space on the first page.
(All the memo-components was added to a TList (MemoList) in order to control
the components.)
But I don't get the memo-components to show in my report (in the group
footer band). Maybe I get the Top and Left properties wrong?
(And how do I set the width in order to use almost all the page width?)
The new memo components should be shifting relative to the previous memo
component.
Roughly, my code in the DBMemoOnprint event looks like this:
Memo := TppMemo.Create(GroupFooterBand2);
Memo.Band := GroupFooterBand2;
Memo.Stretch := True;
Memo.Width := 100; { What should this be in order to use the page
width? }
if MemoList.Count = 0 then
begin
Memo.Left := 0; { Is this correct? }
Memo.Top := 0; { Is this correct? }
end
else begin
Memo.ShiftRelativeTo := TppMemo(MerknadListe.Last); { Can't I do
this? }
end;
Memo.Lines.Add(DBMemo.Lines.Text);
MemoList.Add(Memo);
Then I tried to set the ShiftRelativeTo property of the first created memo
component to the MemoDesign component (from part 1) which is still in the
report. This time the first memo component shows correctly, but still all
the other memo components are "missing".
I have spent hours trying to solve this problem. What am I doing wrong? Is
there a better solution to my problem (in part 1)?
TIA,
Jon-Egil Borch
This discussion has been closed.
Comments
1. Is you DBMemo set to stretch? If so, it should overflow correctly to
the next page. If not, you will need to set the ReprintOnOverflow property
to True to get this effect.
2. I'm a bit unclear about what you are ultimately trying to accomplish.
Why are you copying information from another component in the report? Why
not get the text directly from the database? Perhaps a visual
representation of what you would like your report to look like will help.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Ok. I'll start with a visual representation of the report. For simplicity,
let's sat the records in DB have three fields: Name, Value, and Comment. the
comments may be long, and two or more records may have the same comment.
It's important to use as less space as possible in this report, that's why I
do all this strange things. One page in the report may look like this:
*****************************************************
Some page header
----------------------------------------
Some group header
----------------------------------------
< Here is the detail band >
Record no 1 Value1 1)
Record no 2 Value2 2)
Record no 3 Value3
Record no 4 Value4 3)
Record no 5 Value5 2)
Record no 6 Value6 4)
----------------------------------------
< Here is the group footer band >
1) This is the comment for record no 1. And
this comment may use more than one line.
2) This is the comment for record no 2 and 5.
3) This is the comment for record no 4.
Line two of the comment.
Line three of the comment.
4) This is the comment for record no 6.
----------------------------------------
Some page footer
*****************************************************
As you can see, I want to put the comments in the group footer band, and
only use a reference number in the detail band.
1. The detail band has a DBMemo for the comment, but the visible property is
set to False. Instead, the text in the DBMemo is copied to the memo
component in the group footer band. It's the memo in group footer band I
have called "MemoDesign" (i.e. a memo put in design time). This is NOT a
DBMemo, and yes, the Stretch property is set to True.
And it does not overflow correctly. When there's no space left on the page,
the remaining comments are not shown in the next page. (But the report has
made an extra page...) I tried setting ReprintOnOverflow (in run time,
because this menu was of some reason disabled in design time), but then only
the 1)-comment would show. All the others were gone.
2. As I tried to explain: Instead of having one memo copmponent in the group
footer band, I tried to put all the comments in seperate memo components
created in rume time. But I can't get the runtime memo components to show in
the group footer band. (Only the first will show if a set ShiftRelativeTo
property to the design time memo component (MemoDesign). (MemoDesign is of
no other use in this part.)
Hopefulle, this will clarify my goal.
Regards,
Jon-Egil Borch
Thank you for the explanation.
Have you considered placing a subreport inside your Group Footer and
traversing the data again, placing only the memos in the subreports detail
band? This may make things a bit easier than moving data from one component
to another. Also, setting the ReprintOnOverflow property when Stretch is
True will have no effect, because when a component is set to Stretch, it
implies that you will want it to reprint on a page overflow.
If you are still unable to resolve this issue, please put together a small
example I can run on my machine that demonstrates this behavior and send it
in .zip format to support@digital-metaphors.com.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for the tip about the subreport. This way, the comments indeed wrap
to the new page. But my new problem is that I need to have a master-detail
relationship because the subreport should only show the comments for records
in the group. I probably have to connect the subreport to another SQL
statement, and that SQL has to get an ID from the main SQL. But I don't know
how to do this.
(We design the reports in our dynamic report application, and not in Delphi.
Therefore we write SQL statements, connect the report fields to the SQLs,
and do not have any control over any Delphi datasets.)
And I have another problem:
As I described, I use a reference number to give each comment-memo a new
number.
But in what event do I reset this reference number? For example, I can't use
the BeforePrint on the group header, because then the reference number will
reset on every new page if the detail band wrap to more pages.
I thought I had the answer: reset in BeforeGroupBreak. But the numbers are
not correct if I turn over the pages backwards... However, this seems to be
correct if I set CachePages to True. Is this the only solution?
Regards,
Jon-Egil Borch
I'm unclear about exactly how you are connecting data to your report. There
are three ways to set up a master/detail relationship in ReportBuilder. See
the article below for information on the first two. Third, you can use the
Data workspace (DADE) and create your datasets visually from within
ReportBuilder.
Using the BeforeGroupBreak may work in this case but we cannot guarentee
that this event will only fire once per group break. If you find in the
future that you are not receiving the correct values, this may be the cause.
Setting the CachePages property to True is the easiest solution to this
problem because the BeforeGroupBreak is firing when you are moving forward
and backward through the pages, more than likely causing the value problems.
------------------------------------------------
TECH TIP: Fundamentals of Report Data Traversal
------------------------------------------------
1. Single Table Listing Report
Assign the Report.DataPipeline property and leave the
DetailBand.Pipeline unassigned.
The report will traverse the data from start to end (based on the
datapipeline range settings and honoring any filters you've placed on
the datset etc.)
2. Master/Detail Report:
A. Assign the Report.DataPipeline property to the master. Create a
subreport in the detail band and assign the childreport.DataPipeline to
the detail datapipeline.
Use either the visual linking features available from the Report
Designer's Data tab, or Use standard Delphi dataset linking to define
the relationships between the datasets.
The Report will traverse the master records and for each, the subreport
will traverse the detail data related to the master.
3. Master with 2 Details
Configure as in 2 above. Add an additional subreport to the detailband.
Set subreport.ShiftRelativeTo property to the point to the first
subreport. Connect the ChildReport's DataPipeline to the detail data.
4. Report connected to no datapipelines.
When Report.AutoStop is set to True, the Report will print a single
detail band.
When Report.AutoStop is set to False, the Report will print detail bands
until instructed
to stop. You can control when the report stops by setting the
Report.PageLimit property or by calling Report.DataTraversalCompleted
method. Otherwise the report will never stop.
Additional Notes:
----------------
1. SubReports have a Report property that is of type TppChildReport.
Thus, programmatically you can code SubReport.Report.DataPipeline :=
myDataPipeline.
2. ChildReport's traverse data following the same rules as above. A
ChildReport prints in its entirety each time it gets a turn to print.
3. For a Child style SubReport use the Title/Summary band rather than
the Header/Footer (or use a GroupHeader/GroupFooter combo). A standard
Header/Footer will not work because these always print at the very
top/bottom of the page.
4. Do not filter the dataset of modify it any way once the report.Print
command is issued. If you need to do master/detail and cannot use
linked datasets, then use the master DataPipeline.OnRecordPositionChange
event to filter the detail dataset.
5. The reports and datapipelines use dataset bookmarking. Make sure
the dataset can support bi-directional navigation.
Check out the RBuilder\Demos\Reports\Demo.dpr project. Reports 0071,
0072, 0073 show examples of master w/mutliple detail style reports.
Number 0072 has two detail reports.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com