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

Skipping to a specified label

edited May 2004 in General
I have a need to make the application skip to a specific label position. I
found a prior post that provided a sample SkipLabels.zip. I went through
that example and was successful at making it work.

However, in my application I am storing the reports in the database and
opening them, running in designer to preview, etc. The events such as
OnStartFirstPass, OnStartSecondPass and ppDetailBand1BeforePrint do not seem
to fire if I load the report from database. I am sure I am overlooking
something simple.

Is the example in SkipLabels.zip the correct way to handle printing at a
certain label position even if you are loading reports from the database?
If so, how do I make the events fire? If not, what is the best solution?

Thanks,
Bob

Comments

  • edited May 2004
    Hi Bob,

    The easiest solution would be to code something similar to the SkipLabels
    example in RAP for each template that needs this functionality. See the
    article below for more information why this is happening.

    --------------------------------------------
    Article: Troubleshooting Lost Event Handlers
    --------------------------------------------

    Let's assume you have created a report in Delphi and assign an event
    handlers to the OnPreviewFormCreate event of the report. The event is
    generated by Delphi as:

    procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);

    You then save the report to an RTM file 'Report1.RTM.' The events are
    stored as references only, and so the RTM contains:

    object ppReport1: TppReport
    .
    .
    OnPreviewFormCreate = ppReport1PreviewFormCreate
    end

    You then go on to work on a different report. Saving it with under then
    name 'Report2.RTM'. Only this time, before you save the report you
    change the report component name to: rptOrders. Delphi automatically
    updates the event declaration for OnPreviewFormCreate event to:

    procedure TForm1.rptOrdersPreviewFormCreate(Sender: TObject);


    You then create two buttons on the form, one to load Report1 and
    preview, the other to load Report2 and preview. When you run the app
    and click Report1, you an error. This is because the Report1.RTM file
    contains a reference to ppReport1PreviewFormCreate, a method which no
    longer exists (at least with this name) in the form.

    One answer is to load all your rtm files into the report component you
    will be using for loading. Fix any errors, reassign any events that get
    cleared. This will update your rtms to contain the proper event handler
    names.


    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2004
    I have RAP, can you point me in the right direction with RAP? How would I
    go about accomplishing the specification of a specific label to print to in
    RAP?

    Thanks,
    Bob

  • edited May 2004
    I have been working with RAP but have not found a way to accomplish the
    "skip to label position" issue. I am sure there is a way. Can you provide
    me some direction? Also, how will I pass the value to the RAP variable from
    the application?

    Your assistance will be greatly appreciated.

    Thanks,
    Bob

  • edited May 2004
    Hi Bob,

    Sorry for the delay. I went ahead and created close to the exact example
    using RAP and Report Parameters for you. Hope this helps.

    http://www.digital-metaphors.com/tips/SkipLabelsRap.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2004
    That was very helpful and I now have it working very well. There is one
    concern I have. As my users make report changes, they must go to the two
    functions and enter their DBText and Label components Visible properties.
    Is there a way to adjust those functions to make them set the visible
    property to true / false of all objects in the detail band? In other words,
    as it stands now, if the end user decides to add an additional field to the
    label, they must edit the code in two places. It would be nice if I could
    loop or otherwise enable / disable all objects in detail band to keep down
    support from end users. Is there a way to do that?

    Thanks,
    Bob

  • edited May 2004
    Hi Bob,

    You might try placing a TppRegion inside the detail band with its
    ParentHeight and ParentWidth properties set to True. Then your users will
    be forced to place their components in the region and you can just toggle
    the visibility of the region to hide every component in the band.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2004
    That will work.

    Thanks,
    Bob

  • edited May 2004
    It looks like a region prints a box around it. Is there a way to turn that
    off? Surely I am missing something. The region idea works great except
    with labels, we don't want the square around it.

    Thanks,
    Bob

  • edited May 2004
    Hi Bob,

    You're going to want to set the TppRegion.Pen.Style property to psClear.
    This is a published property so it can be set in the Delphi Object Inspector
    at design time.

    --
    Best Regards,

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

    I'm very new to RB. I use version 9.03 enterprise.

    I've looked at the project:
    http://www.digital-metaphors.com/tips/SkipLabelsRap.zip

    When I execute this project and enter 5 labels to skip, then it will do just
    fine.
    But when I close the preview and press the preview button again the 5 labels
    will not be skipped anymore. (same goes for any other number of labels to
    skip.)
    Could you please tell me what should be changed to the project?

    Regards,
    Stef
  • edited November 2005
    Hi Stef,

    Try calling ppReport1.Reset at the beginning of the ButtonClick event. This
    should solve the problem.

    --
    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.