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

Setting subreport AutoSearchCriteria from RAP

edited June 2008 in RAP
Hi,

D20007, RB 10.08, end user solution using RAP.

I have a main report which contains a sub report. The main report contains
an autosearch value which limits the report to a date range between 2 dates.

The sub report also needs to select between the same two dates but if it has
it's own autosearch criteria defined up front, the auto search dialog shows
two tabs and the user must enter the same date range twice which is not
elegant.

I wanted to add an auto search criteria for the subreport from within the
OnGetAutoSearchValues event of the main report but it doesn't seem to work.
The sub report continues to show data but does not respect the date range.

I also need a way to prevent the second auto search criteria from appearing
on the auto search dialog if the user happens to preview the report multiple
times. Currently, there does not seem to be a way to remove just one auto
search criteria. I also note that Report.FreeAutoSearchFields does not
compile within RAP.

Is there a way I can get this to work?

my RAP code is:
procedure ReportOnGetAutoSearchValues;
const
SubReportPipeline = 'Durations';
SubReportSearchField = 'Visit Date';
var
AutoSearchFld: TppAutoSearchField;

begin
AutoSearchFld := Report.AutoSearchCriteriaByName(SubReportPipeline,
SubReportSearchField);

if AutoSearchFld = nil then
AutoSearchFld := Report.CreateAutoSearchCriteria(SubReportPipeline,
SubReportSearchField, soBetween,
Report.AutoSearchFields[0].SearchExpression, False)
else
AutoSearchFld.SearchExpression :=
Report.AutoSearchFields[0].SearchExpression;

end;

Regards, Paul.

Comments

  • edited June 2008
    Hi Paul,

    1. Try using the TdaSQLBuilder object to update the search criteria of the
    subreport with the same values as the main report. See the TdaSQLBuilder
    topic in the RBuilder help for code examples.

    2. You would need to create a custom autosearch dialog in order to remove
    the tab shown for the subreport. Another option would be to simply remove
    the autosearch fields from the subreport and update its search criteria
    directly using the TdaSQLBuilder as described above when the initial
    AutoSearch values are entered.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2008
    "Nico Cizik (Digital Metaphors)" wrote in
This discussion has been closed.