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

ppReport Template question

edited September 2001 in General
Hello,

I have a ppreport and ppdesigner components on a form. I allow the user to
modify the built-in report and save it as a file. All works ok here. I set
the template.filename property and use the LoadFromFile so the user's custom
report is loaded the next time they run the report. However, I would like
to give the user the option to go back to the default report. I have tried
clearing the template.filename property, with partial success. If the
application is closed and re-started it works ok but if the application is
not closed and restarted the original built-in report is not reloaded. What
am I missing here? Any help is appreciated.

Thanks in advance!
Dan S.

Comments

  • edited September 2001
    Hi Dan,

    the initial report is a resource of the application and red upon form
    creation. You have to recreate the form if you want the built-in report.
    I prefer having all reports as file (or record) and not inside the
    application.
    You can create a default report as file like the user's reports, or you can
    save the built-in report as file or stream before loading the user's one.

    regards,
    Chris Ueberall;

    Dan S. schrieb in im Newsbeitrag:
    8EAE82296ACCD311A039005004E0CAC004D6EE@DMSERVER...
    to
    set
    custom
    tried
    What
  • edited September 2001
    Hi Chris,

    Thanks for your help! I'm not sure how to save the template to a stream. I
    tried creating stream variables and setting them but that that did not work.
    Do you have a small piece of sample code to clarify how this is done?

    Thanks in advance
    Dan S.


  • edited September 2001
    Hi Dan,

    I
    work.

    from scratch ...

    var
    memStream : TMemoryStream;

    begin
    memStream.Create;

    try
    myReport.Template.SaveToStream(memStream);

    myReport.Template.LoadFromFile;

    // doing something with the layout ...

    memStream.Position := 0;
    myReport.Template.LoadFromStream(memStream);
    finally
    memStream.Free;
    end;

    (see Help and Demos, streams are essential but easy and very robust).

    regards,
    Chris Ueberall;
  • edited September 2001
    Hi Chris,

    I Tried following your example but the program is producing an access
    violation when the SaveToStream command is being performed. Any clues on
    this?

    Thanks in advance and I appreciate your help!
    Dan S.


  • edited September 2001
    Hi Dan,

    Sorry, but I'm an idiot!

    memStream.Create;

    should be

    memStream := TMemoryStream.Create;

    You didn't see the compiler's warning?

    regards,
    Chris Ueberall;
  • edited September 2001
    Hi Chris,

    That was it! Thank you for all your help. No I did not notice any compiler
    errors, just an access violation when running the program.

    Thanks again!
    Dan S.

  • edited September 2001
    Hi Dan,


    not an error but a warning about the missing initialization, I recommend the
    use of the project.compiler options 'Show Warnings' and 'Show Hints'.

    Cheers,
    Chris Ueberall;
This discussion has been closed.