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

LoadFromDatabase

edited December 2001 in General
I want to load a report from a database using LoadFromDatabase however it
seems to take only the reportname as a parameter. If there are two reports
with the same name but in different folders then only one report can
possibly be loaded. In my case I know exactly what record I want to load
the report from and was wondering if there was a way to Load the report from
the current record.

Thanks in advance for you help.

Scott

Comments

  • edited December 2001
    Yep, the Template.LoadFromDatabase will look for a report by that name, and
    it doesn't expect multiple instances of that report name in the table.
    You'll have to adapt our code to work the way you want. The code which does
    the dirty work is in ..RBuilder\Source\ppTmplat.pas,
    TppTemplate.LoadFromSource.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited December 2001
    Hi Scott,


    ---------------------------------------------------------------
    Tech Tip: How to Programmatically Load Reports that were Saved
    using the Report Explorer
    ---------------------------------------------------------------

    1. The ReportExplorer has a run-time interface you can use to load
    reports using the ReportExplorer.LoadReport method. You can use this
    method without actually 'showing' the report explorer form. (See the
    online help topic for TppReportExplorer.)

    2. If you want use Report.Template.LoadFromDatabase, RB will locate the
    report stored in the database table based upon the NameField value only.
    However, for the rb_item table you really need Folder_Id, Name to locate
    a record uniquely.

    To override this default behavior, you can assign an event-handler to
    the Report.Template.OnLocateRecord event.

    example:

    TmyForm = class(TForm)
    private
    function ReportLocateRecordEvent(Sender: TObject; const
    aReportName: String): Boolean;

    end;

    procedure TmyForm.FormCreate(Sender, TObject);
    begin
    {assign the event handler}
    FReport.Template.OnLocateRecord := ReportLocateRecordEvent;

    end;


    function TmyForm.ReportLocateRecordEvent(Sender: TObject; const
    aReportName: String): Boolean;
    begin
    {add logic here to locate the record and return True if it is found}

    Result := myLocateReportFunction(FFolderid, aReportname);

    end;



    regards,
    Chris Ueberall;

  • edited December 2001
    Thanks!!

This discussion has been closed.