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

Prevent a template from loading

edited September 2005 in General
Hello,

I have a form which can print any kind of template loaded from a database.
In my case I have two templates - an invoice and just an order, off of the
same data. The user can load and print any template.

I want to prevent the user from loading and printing the invoice template,
if he hasn't entered all the needed fields for the template. Mind you, I
have no control over which template he will load (i.e. I can not just hide
certain templates before loading).

Is it possible to write such RAP code, that will prevent a certain template
from loading (most important is to disable the printing), based on some
random code INSIDE the template? The idea is that the user must not be able
to print an incorrect invoice with some important fields missing.

Thank you!

Dimitar Selenski

Comments

  • edited September 2005

    As an example, I modified the RBuilder\Demos\EndUser\ReportExplorer as
    follows:

    1. Use OnFormCreate event of the end-user form to assign the
    event-handler...

    ppReport1.Template.OnLoadStart := LoadStartEvent;


    2. Implement the event to perform the validation and raise an exception to
    prevent the report template from being loaded

    procedure TmyEndUserSolution.LoadStartEvent(Sender: TObject; aStream:
    TStream);
    begin
    if (ppReport1.Template.DatabaseSettings.Name = 'Invoices') then
    raise EReportBuilderError.Create('Access denied');
    end;



    --
    Nard Moseley
    Digital Metaphors Corporation
    http://www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.