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

which is the best method to do this??

edited May 2005 in General
Hi!

I'm using RBuilder Pro 7 and Delphi 7 Pro.

Some months ago I asked for a solution for my problem, and it worked,
BUT not as fine as I thought...

What I need is...
I have a Table with the following records:

STOCK PRODUCT
3 Product 1
4 Product 2
1 Product 3

I want to print 3 labels for product1, 4 for product 2, 1 for product 3,
etc...
I mean... I want to print labels "per stock".

To make this possible, I use the
"ppBDEPipeLine.RecordPositionChange" event.

When this event fires, I check how many units has the current product
and change the "BandsPerRecord" property of the DetailBand, by code.

This is my code for that event:

for liBand := 0 to loader.BandCount-1 do
for liObject := 0 to loader.Bands[liBand].ObjectCount-1 do
begin
lObject := loader.Bands[liBand].Objects[liObject];
if (lObject is TppSubReport) then
begin
lChildReport := TppSubReport(lObject).Report;
for liBand2 := 0 to lChildReport.BandCount-1 do
begin
if lChildReport.Bands[liBand2] is TppDetailBand then
with lChildReport.Bands[liBand2] as tppdetailband do
BandsPerRecord:=form1.table12.fieldbyname('STOCK').asinteger
end;
end;
end;

It works fine on the first page of the report, but if one product
doesn't 'fit' on the first page, and has to continue on the next page,
it will not be printed, and there are repeated records, etc...

Sorry, but I can't use DetailBand.OnPrint event or similar, because I'm
using pre-saved .RTM reports.

Please, I need to solve this problem. I can send you an example
application with some data if you need it. Maybe you will understand it
better with a sample application.

Thanks!

Comments

  • edited May 2005
    Hi Santy,

    The datapipeline does not have a concept of pagination so these events will
    fire regardless. This is probably the reason you are getting incorrect
    results when the page breaks.

    If you are unable to use the report events, I would suggest first tracing
    your current event code with the RB code to find out exactly what is
    happening when the page breaks to cause the incorrect results. Once you
    find out the problem, you will need to experiment a little with the events
    you do have access to to find a solution. For instance... if you are using
    static height labels, you can probably calculate how many records it takes
    to fill up a page. Therefore, you will know when a page break will occur
    and plan for that accordingly.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2005
    Hi, Nico...

    I sent you a sample application with code that explains the problem.
    There you can see what I mean. I noticed the reason of the problem and
    it is better explained on tha sample app.

    Please tell me if you didn't receive it, because I haven't received
    receipt response.

    Thanks again!

  • edited May 2005
    Hi Santy,

    Yes, I received your example, however my answer still remains the same. The
    pipeline events have no knowledge of pagination in a report. This is the
    reason your report works correctly until a page break occurs. To perform
    this operation correctly, you will need to use report events such as the
    DetailBand.BeforePrint event. Getting access to these events can be done
    very easily using RAP if you do not have access to the Delphi code of each
    report. RAP allows you to keep all your event code local to each template
    removing the need for Delphi event code in the pas file. For more
    information on RAP see the following web page.

    http://www.digital-metaphors.com/Subpages/Products/Enterprise/Code.html

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2005
    Thanks, Nico...

    But I solved it with a simple "ppreport1.ResetFromPageNo(0)".
    Now it prints everythink ok! :)


  • edited May 2005
    Excellent! Glad you got it working.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.