Home RAP

AutoSearchCriteria

edited October 2008 in RAP
When using "custom" sql, I find it necessary to create the autosearch
criteria in rap code
to alter my sql at runtime.
I use the OnInitializeParameters event. All works ok EXCEPT a cosmetic
glitch. Each
subsequent time I run the report, the search criteria is added. So on the
second run there are
4 criteria, on 3rd 6 criteria, etc. I don't know how to clear the criteria
nor do I understand
why they are being "saved". Any help would be appreciated. Thanks

Below is the code

Var
MySQLBuilder: TdaSQLBuilder;
MySQLText: TStrings;

begin
MySQLText:=TStringList.Create;
MySQLText.Clear;

MySQLBuilder:=TdaSQLbuilder.Create(Report.DataPipeLine);
MySQLBuilder.SearchCriteria.Clear;
MySQLBuilder.ApplyUpDates;
MySQLBuilder.Free;
MySQLText.Free;
Report.ShowAutoSearchDialog:=True;
Report.CreateAutoSearchCriteria('PFile','File
Number',soEqual,'612553',True);
Report.CreateAutoSearchCriteria('PYear','Report
Year',soEqual,'2007',True);
Report.ShowAutoSearchDialog:=True;

{aCancel := False;}

end;

Comments

  • edited October 2008


    1. RB 11 includes AutoSearch and Visual Linking support for manual edited
    SQL. No code is required.

    a. From the Design workspace you can add Parameters and configure the
    Parameter.AutoSearchSettings properties and LookupSettings to control the
    ask at runtime behavior.

    b. From the SQL Editor, you can include :ParamName references. At runtime
    the :ParamName is automatically replaced with the param value.


    2. For the solution you have now, I recommend adding a check for
    AutoSearchFieldCount

    if (ppReport1.AutoSearchFieldCount = 0) then
    // create autosearch fields




    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2008
    Hi Barry,

    Before creating the AutoSearch criteria, first check to see if it already
    exists.

    var
    AutoSearchFields: TppAutoSearchField;
    begin
    ...

    AutoSearchFields := Report.AutoSearchCriteriaByName('PYear','ReportYear');
    if AutoSearchFields = nil then
    AutoSearchFields := >
    Report.CreateAutoSearchCriteria('PYear','ReportYear',soEqual,'',True);
    AutoSearchFields.SearchExpression := '2007';

    ...
    end;

    I create AutoSearch criteria on the OnCreate event of the report using the
    above technique and it work well for me.

    RB 11 has the ability to create Parameters and assign them directly to the
    Search criteria of the pipeline in the DADE. This is a great new addition
    to RB and is much more flexible and simple approach. If you have not
    already done so, updgrading to RB 11 is well worth it as it has a lot of
    great new features and enhancements that will immediately be useful and
    simplify your development of reports.

    Anway, I hope that at least points you in the right direction.

    Scott

This discussion has been closed.