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

TppRichText Fields & Mailmerge

edited November 2001 in General
I've run into a problem trying to generate letters using TppRichText &
mailmerge....

I get one result when I page through using preview; however, I get another
result when I print the letters....

I have the need to generate one of 10 letters for a client... based upon
various criteria determined by the customer. I have created a table of
client data... containing name, address, city, state, zip, etc... along with
a LetterCnt (value 1-10) to specify which letter the client should receive.

I then defined an array of TppRichText...
..
.
var
ppLtrText : array[1..10] of TppRichText;
.
.

In the before print event of the Report I load the various letters into the
TppRichText array and set visible to false;
.
.
Cnt := 0;
While not LetterTable.EOF do
begin
inc(cnt);
aStream := TmemoryStream.Create;
try
TBlobField(LetterTable.FieldByName('Ltr_Text')).SaveToStream(aStream);
aStream.Position := 0;
ppLtrText[cnt] := TppRichText.Create(Self);
ppLtrText[cnt].Band := ppDetailBand1;
ppLtrText[cnt].spLeft := 96;
ppLtrText[cnt].spWidth := 576;
ppLtrText[cnt].Stretch := true;
ppLtrText[cnt].Visible := false;
ppLtrText[cnt].MailMerge := false;
ppLtrText[cnt].LoadFromRTFStream(aStream);
finally
aSteam.Free;
end; { try/finally }
LetterTable.Next;
end;
.
.
.
In the before print event of DetailBand1 I have:
.
.
var
cnt : integer;
begin
for cnt := 1 to 10 do // make sure visible is false for all TppRichText
in the array
begin
ppLtrText[cnt].visible := false;
ppLtrText[cnt].mailmerge := false;
end;
cnt := ClientTable['LtrNbr']; // get letter number to print from client
table and make it visible
ppLtrText[cnt].visible := true;
ppLtrText[cnt].mailmerge := true
end;

If I page through the report one page at a time the correct letter is
displayed; however, if I select to print all of the pages from the preview
only the Letter "1" is printed... and subsequent viewing via the preview
after the print to the printer displays only Letter "1"... although
ClientTable['LtrNbr'] contains other values.... (confirmed with displays in
the before print event of DetailBand1).

Any Ideas?

Joe Hutchins

Comments

  • edited November 2001
    Set the richtexts ShiftRelativeTo the previous richtexts, since they are
    stretching.

    When you place a breakpoint on the line:

    ppLtrText[cnt].visible := true;

    What is the value of cnt as each page is printed? If you are in the
    Detailband.BeforePrint (this is the correct event to use), you should be
    able to set the visibility of the rich text.

    Is the datapipeline always connected to the report?

    Perhaps, take the rich texts out of the equation. Just try to print shapes
    by setting their visibilityin the same manner as you are doing for the rich
    texts.

    On a side note, you may want to create N number of "SectionStyle" subreports
    and drop each letter into one of these subreports. This will force each
    subsequent letter to print on a new page.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited November 2001

This discussion has been closed.