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

Problem with template.loadfromdatabase

edited July 2003 in End User
My application is based on the enduser examples using a custom report
explorer. The user can add any number of reports in the report explorer
to a list and then from the main form they can select to print any in
the list from a check list box. There is a button on the main form to
start the printing process.

All is fine if the report explorer hasn't been executed ie the selected
reports print ok if the program has just started. As soon as I execute
the report explorer and return to the main form the
template.loadfromdatabase procedure fails. I'm missing something I know
so any ideas on what would cause this to occur would be welcome.

I can't reproduce this with the RB enduser examples only with this
project.

using RB6.03 and D5.

Comments

  • edited July 2003
    I also have the same problem. After custom ReportExplorer execution
    LoadFromDatabase from separate button returns an exception which states that
    the report with such name could not be found. I even tried to write my own
    Template.OnLocateRecord method, but it didn't help.

    I think that the cause is that loading from custom ReportExplorer changes
    some properties of the report template.
    Afterwards loading report with the LoadFromDatabase method uses the same
    report template but with properties changed earlier by Report Explorer.
    However I also don't know what property causes report misbehaviour.

  • edited July 2003
    I have a problem calling a "AoadFromDatabase" print job wherein the
    printername is set dynamically and the report is sent to the printer without
    any user interaction. I get an access violation when calling all of this
    from the main form of my midiapp. If I move the code to a form other than
    the main form everything works just fine. This is not a problem for me
    because I don't need to use this code on the main form I was just using the
    main form to test it and it took me a few hours to realize what the problem
    was. I don't know why this is.

  • edited July 2003
    One thing that may be causing the problem is if there are components that
    are not owned, ie. data pipelines and data access components that are
    created at runtime in your code should have an owner that is the form or
    datamodule in the application. We use Screen.Forms[] and
    Screen.Datamodules[] array properties to locate such objects. In any case
    that one of your event handlers references Report.Datapipeline it could be
    nil if it wasn't visible or had no owner. RB templates save a string for the
    data pipeline component name so that when it is loaded from template to an
    object, RB builds a list of visible pipelines in the app and ID's a pipeline
    object in the list by its name so that it can restore the object reference
    property to the pipeline on a report or subreport.


    Cheers,

    Jim Bennett
    Digital Metaphors
  • edited July 2003
    It's good to know I'm not alone with this. I don't think it is the custom
    explorer as I just tried the tutorial for the custome explorer with a button on
    the main form to .loadfromdatabase and it works fine after executin the custom
    explorer. The answer must be in our own code somewhere.
  • edited July 2003
    I was wrong, the problem can be reproduced in the demos but the problem is not 100%
    consistent

    Using the demo end user report explorer:

    Change the code so the main form shows and also change the code so the Launch btn
    executes the explorer not the timer.

    Add a button and put the following code inside

    ppReport1.Template.DatabaseSettings.DataPipeline:=plItem;
    ppReport1.Template.DatabaseSettings.NameField:='Name';
    ppReport1.Template.DatabaseSettings.TemplateField:='Template';
    ppReport1.Template.DatabaseSettings.Name := 'Customer List';
    ppReport1.Template.LoadFromDatabase;

    Run it and press the button - report template loads ok

    launch the explorer then close it and press the btn again - usually fails

    launch the explorer again and preview Customer List report then close the explorer
    and press btn - ok

    launch the explorer again and preview another report like Order Summary then close
    the explorer and press btn - fails

    Could someone at DM have a look at this
This discussion has been closed.