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

Events and LoadFromDatabase

edited March 2003 in End User
Hello,

I want to give the ability to the users to modify the reports of my
application. The way I choosed to do this is the following :
-I distribute the reports embedded in the executable.
-If the user want a custom version he clicks on a button in the preview form
(I created a new print preview form) and the standard report (the one
embeded in the exe) is saved in the database. My table is made of 2 fields
(NOM varchar(100) and MODELE blob)
-When I execute a report, I check the database, if a version of the report
exist I load it so I print the modified version. Of course, if such a
version doesn't exists, I print the standard report.

What I still have to do is to give the ability to load the stored reports in
the designer and to edit them. So I created an application just to do this.
I have in a DataModule a TIBDataSet and a TDataSource to access the table, a
DBPipeLine, aTppReport and a TppDesigner.
The pipeline is connected to the DataSource.
The Report is empty.
The designer is connected to the report

My code is

with DmComposants.ppEtatModif.Template do
begin
DatabaseSettings.Name := FieldByName('NOM').AsString;
LoadFromDataBase; <------------error
end;

DmComposants.ppDesigner.ShowModal;

The error is : Error reading ppEtat.OnEndPage: Invalid property value

I tried the same code without the LoadFromDatabase. The designer is
launched. And when I do File/Open, I get the list of the reports stored in
the database, but I also get the same error when opening a report.

For information, I have one "abstract" report that provides footer for all
my reports. It's shared between many applications. All my reports derive
from this abstract report, some are even also "abstract" ...

Well, that was a pretty long post but I'm really stuck with this.

Thanx (a lot) in advance,

Julien

Comments

  • edited March 2003
    What is happening here is that the report template was saved down with this
    OnEndPage event handler assigned. When the template is loaded, it tries to
    establish this connection again. However, the streaming logic was unable to
    locate the event handler on the form/datamodule in which the template is
    being loaded, so it could not assign the event property of the
    Report.OnEndPage. Check out our templates thread of our tech-tips newsgroup
    for more explanations on losing event handlers. One solution is to use RAP
    to locate the event handlers in the template, or code the OnEndPage event in
    the datamodule where the report template is to be loaded. However, this
    means that any objects that are referenced by name in the event handler will
    have to be on the form, otherwise, you'll get a compile error. This is why
    RAP has such an advantage, as you can store the code in the template and not
    in a Delphi unit's event handler.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited March 2003
    OK, I tried to move my code from Delphi to RAP. Now my problem is that I
    don't have all the methods and properties I used to have in Delphi. The
    Summary.PrintPosRect is gone. It does'nt appear in the object Pane of the
    code editor. Any advice ?

    Thanx

    Julien

  • edited March 2003
    Yes, this is not surfaced in RAP. Here is an example which adds RAP pass
    through functions to support manipulation of draw commands on the page. It
    includes one function that is called PrintPosRectTop which returns the
    Report.Engine.PrintPosRect.Top from a RAP pass through function. You could
    add a function in which you pass the band to get the value and another
    function to set the value.

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


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.