Parameters in subreport

Enviroment: End-User

I have Report with subreport as "Header".
This Subreport is dynamic loaded by procedure "LoadFromFile". Loaded Report(subreport) has own dataset with parameter.
How can I supply value into that parameter ?

Header has subscribe information about Company. I would like supply value company_id into search parameter.

Thank you

Ikac

Comments

  • Hi George,

    Parameters are only supported in the main report and are not currently transferred from loaded templates into subreports. In our testing, we found there was an AV when trying to load a template with parameters into a subreport and that is fixed with a patch for RB 21.02.

    To get the effect you are after, you will need to add the parameter to the main report before loading the template. Then, using the TdaSQLBuilder, re-assign the parameter from the main report to the search criteria loaded with the subreport. Something like the following after the template is loaded:
    procedure TForm2.CreateParameters;
    var
    lParameter: TppParameter;
    lDataView: TdaQueryDataView;
    lSQLBuilder: TdaSQLBuilder;
    lCriteria: TdaCriteria;
    begin

    lParameter := ppReport1.Parameters[‘company_id’];

    lDataView := TdaQueryDataView(ppReport1.DataPipeline.DataView);

    lSQLBuilder := TdaSQLBuilder.Create(lDataView.SQL);
    try

    lCriteria := lSQLBuilder.SearchCriteria[0];

    //lCriteria.Value := lParameter.Value;
    lCriteria.ParamName := lParameter.Name;

    lSQLBuilder.ApplyUpdates;

    finally
    lSQLBuilder.Free;
    end;

    end;
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Thank you :) It is difficult solution for me :(

    My idea:

    Subreport "header" has own dataset in data Tab with search option. Rtm file so contains search option.
    I could before LoadFromFile change value of parameter in rtm file and It could be works .

    Better solution could be load rtm to memory, there to change value parameter and loadFromStream to template.

    Is this solution suitable ?

    thank you :)
  • edited October 29
    Hi George,

    This could be a possible solution however it seems like a lot of work to parse the template source :).

    One option would be to create another TppReport object, load the template and change the search criteria manually, resave, and load the template into your subreport.

    If you are concerned that you do not want to add the code for every one of your existing reports, it would be possible to add the code once in the Template.OnLoadEnd event which would then be applied to any template loaded with your application.

    Another option would be to create a RAP passthru function that does this. Then you would only need to add a single line of RAP code to each report template (perhaps in the OnInitializeParameters event).


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
Sign In or Register to comment.