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

OnPreviewFormCreate = ppReport1PreviewFormCreate

edited September 2003 in End User
I often create .rtm files and then run these under delphi control using the
following

ppReport1 := TppReport.Create(self);
with ppReport1 do
begin
Template.FileName := OpenCal.RptDirectory + '\EngSpec.rtm';
Template.LoadFromFile;
PrinterSetUp.DocumentName := 'Engineers Spec '+ DBContract.Text;
DeviceType := dtScreen;
screen.cursor := crDefault;
Print;
end; // end of with ppReport1 do

ppReport1.Free;


Untill recently this has worked fine but I have recently been getting the
following error on newly created reports...

Error Reading ppReport1.OnPreviewFormCreate : Invalid Property
Value

On opening the .rtm file in notepad there is a line

OnPreviewFormCreate = ppReport1PreviewFormCreate

which has not previously been in any report I created. If I manually edit
the .rtm and remove this line the report works fine.

What could I have done to the end user reporting program (which is basically
your end user program with 2 minor mods) - to cause this line to occur?

I do not preceive having changed anything for many months now - everyone is
very happy with Report Builder and its reports.

Thanks in advance

Philip L Jackson

Comments

  • edited September 2003
    Hi Philip,

    You must have saved the template at some point in time with that event
    handler assigned. To work around the problem and correct it, create an event
    handler method on the form so that any report loaded with this event handler
    will assign it. That way you don't get an error message. Or you don't have
    to and ignore the error message. Delphi should handle this case and let the
    property go unassigned. If you have an event handler on the form, then
    you'll need to nil out the event property reference to that event handler
    and then save the report template. Now the report template will be clean
    from that event property. Do this in a loop of all your templates and then
    you can remove the event handler from your form. Another way to fixthe
    problem is to open each template in notepad and remove the entry for that
    event.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited September 2003
    Jim

    I have the following in my end user reporting tool

    procedure TmyEndUserSolution.ppReport1PreviewFormCreate(Sender: TObject);
    begin
    ppReport1.PreviewForm.WindowState := wsMaximized;
    TppViewer(ppReport1.PreviewForm.Viewer).ZoomSetting := zs100Percent;
    end;

    This has been there for two releases of Report Builder and I am confused as
    to why the line has suddenly started to appear in RB Templates?

    Regards

    PLJ

  • edited September 2003
    Hi Philip,

    Check the report's SaveAsTemplate property for those templates. I tis
    propbably set to true. See the help file for more info on this property.
    What is happening is that the report tempalte is being assigned the event
    handler and then it got saved and will try to save that event property
    reference in the template since it is a published event.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.