New Blog Post: PDF/A and Metadata

Issue trying to populate AutoSearch

edited March 2011 in DADE
Hey All -

Using 10.04 Enterprise.

What I want to do is populate an autosearch field with the date range of
the first of this month to today. ( So, for example, on Mar 30, 2011 it
would be 3/1/2011 and 3/30/2011 ).

I've tried creating the Autosearch field in the Dataview with the rest
of the SQL creation, and then using the following code in the
BeforeAutoSearchDialogCreate function:

var
uASF: TppAutoSearchField;
uSDate,
uEDate: Date;
y, m, d: Integer;
begin
DecodeDate( CurrentDate, y, m, d );
uSDate := EncodeDate( y, m, 1 );
uEDate := CurrentDate;

uASF := Report.AutoSearchCriteriaByName( 'Invoice', 'Date' );
uASF.values[0] := datetostr( uSDate );
uASF.values[1] := datetostr( uEDate );
end;

That compiles, but does nothing - my autosearch still comes up with 2
blank dates.

I tried using the example CustomAutoSearch Dialog, but it seems that
example is written for Delphi, and I need this to happen just in DADE.

I tried modifying the example in the following way:

var
uASF: TppAutoSearchField;
uSDate,
uEDate: Date;
uExp: string;
y, m, d: Integer;
begin
DecodeDate( CurrentDate, y, m, d );
uSDate := EncodeDate( y, m, 1 );
uEDate := CurrentDate;
uExp := datetostr( uSDate ) + ',' + datetostr( uEDate );

uASF := Report.CreateAutoSearchField( 'Invoice', 'Date', 'Inv Date',
dtDate, soBetween, uExp, False );

end;

But, when I try to compile that, I get:

Error: ReportBeforeAutoSearchDialogCreate, Line 14: Expected: '(' or
'[', but found 'CreateAutoSearchField' instead.

So at this point - i'm confused. What is wrong with my command to
populate the autosearch, or how do I do so?

Thanks

Chris

Comments

  • edited March 2011
    Hi Chris,

    When you say that you need this to happen in "DADE" I assume you are
    only using RAP code?

    If so, I suggest using the TdaSQLBuilder object to alter your search
    criteria. TdaSQLBuilder is fully supported by RAP and is a much easier
    way to manage the SQL object in code. Take a look at the help topic for
    TdaSQLBuilder for more information and examples of how it is to be used
    to create and edit autosearch fields.

    Also take a look at the SQLBuilder section of the RBWiki for useful
    articles and examples.

    http://www.digital-metaphors.com/rbWiki/DADE/SQLBuilder


    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited March 2011
    Nico -

    Thanks for the repsonse. The issue is that i'm not trying to alter the
    search criteria after selection, or add the results of the criteria to
    another query ( which I can do ! ), but set it so that when the user
    sees the AutoSearch display, it is defaulted with the month to date
    between. So that by default, if the user just clicks ok, its mar 1
    through mar 30, but he could change it to last month, or any other date
    combination. I just want it, by default, to show up with month to date
    figures.

    The closest of the 6 SQL Builder examples your link lead me to was
    Modify Search Criteria - which looks like it replaces the autosearch
    stuff, but doesn't give a good example of how to do it with between dates.

    Any other ideas?

    - Chris

  • edited April 2011
    The examples in the RB Wiki are meant to familiarize you with the
    feature. It is definitely possible to create new autosearch criteria
    using the SQLBuilder. This is all documented in ReportBuilder help
    including how to set up a "Between" criteria.

    Another option you might explore is to use report parameters to populate
    your autosearch criteria with a default value. Take a look a the
    TppParameter topic in the help as well as the following article on how
    to utilize this feature.

    http://www.digital-metaphors.com/rbWiki/End-User/Fundamentals/Report_Parameter_Fundamentals


    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.