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

DB Folder Browse in a sub-classed TppSubReport

edited August 2002 in Subreports
Hello,

I have an end-user application using dictionaries and your custom
report explorer (with minor changes).

I have sub-classed TppSubReport and would like to provide a db folder
browse to the user off of the right click menu of the sub-report
component in the main report. I have tried
'Report.Template.ShowDBOpenDialog' inside of the sub-classed
PopupMenuClick but I get an AV.

I believe it is because the eventual open dialog has no report
explorer assigned. How would I do that?

If I use 'Band.Report.MainReport.Template.ShowDBOpenDialog' I am OK
but it changes the DatabaseSettings.Name of the main report which I
don't want. I am really only concerned with the sub report.

I may not want to actually load the sub-report, at first I just want
the user to select one.

I think I am going at this the wrong way - can you point me back on
track?

Thanks
Rick Matthews
Dartek Systems Inc.

Comments

  • edited August 2002
    You have to override the CreatePopupMenu method and add your TMenuItem :

    procedure TMyHeader.CreatePopupMenu(AOwner : TComponent; var APopupMenu :
    TppPopupMenu);
    begin
    inherited CreatePopupMenu(AOwner, APopupMenu);

    if Assigned(APopupMenu) then
    begin
    FMenuItemSeparator := TMenuItem.Create(self);
    FMenuItemSeparator.Caption := '-';
    APopupMenu.Items.Insert(0, FMenuItemSeparator);
    FMenuItemBrowse := TMenuItem.Create(self);
    FMenuItemBrowse.Caption := 'Browse..';
    FMenuItemBrowse.OnClick := OnClickBrowse;
    APopupMenu.Items.Insert(0, FMenuItemBrowse);
    end;
    end;

    Samuel.


  • edited August 2002
    Samuel,

    Thanks for the help. I had already overridden the CreatePopupMenu.
    My problems started after that with what I was using to provide a
    browse for the user to select the report template from the
    folders/items tables. Do you know what I can use?

    Additionally loading the template (once defined by the user) in the
    overridden local StartOfMainReport procedure (as per the dm provided
    dynamic subreport example) caused problems if the subreport had a
    datapipeline assigned (AV). Any idea what I need to do there?

    Basically I want the user to assign a pre-defined template to a
    sub-report for retrieval when run but allow the user to assign the
    actual datapipleline (if any) as part of the main report.

    Thanks,
    Rick Matthews


  • edited August 2002
    Hi Rick,

    I'm not an expert (yet) but I can tell you what I've done so far. I needed
    something very similar : let the end user drop a dynamically loaded sub
    report and then let them browse the file system for a template.

    I used the CreatePopupMenu to add a 'Browse..' menu and in the OnClick I
    show a TOpenFileDialog. The resulting filename I store in a new property of
    TppSubReport, so that the filename gets stored in the actual rtm file. In
    the StartOfMainReport I then load the sub report template if the
    TppSubReport.FileName exists. It shouldn't be too hard to replace this
    TOpenFileDialog with a database lookup screen.

    When that dynamically loaded report contains a datapipeline
    (TPvQueryDataView) of it's own, I noticed that the whole report would not
    run because the TPvDataSet on the sub report never got initialised. I got
    around that by setting the subreports'
    TPvQueryDataView(Report.DataPipeline.DataView).Active property to False and
    then to True, just after loading the sub report from file. I guess your AV
    might be related to this..

    The only imperfection I am still left with is the fact that whenever you
    preview the whole report, the dataview of the sub report is merged with the
    dataview of the main report, so after 5 previews you end up with 5 times the
    datapipeline of your sub report merged into the main reports' dataview. I am
    still hopefull to solve this last piece of the puzzle.

    Hope this helps,

    Samuel.

  • edited August 2002
    Thanks Samuel,

    That gives me some clues. My current requirements are a little
    different than yours but I would be interested in seeing what you come
    up with (here or email) once you sort out all of your issues.

    Cheers,
    Rick

This discussion has been closed.