Home RAP

Setting subreport AutoSearchCriteria from RAP

edited June 2008 in RAP

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

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;
SubReportPipeline = 'Durations';
SubReportSearchField = 'Visit Date';
AutoSearchFld: TppAutoSearchField;

AutoSearchFld := Report.AutoSearchCriteriaByName(SubReportPipeline,

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


Regards, Paul.


  • 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.


    Nico Cizik
    Digital Metaphors

    Best Regards,

    Nico Cizik
    Digital Metaphors
  • edited June 2008
    "Nico Cizik (Digital Metaphors)" wrote in
This discussion has been closed.