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

AutoSearch Criteria, RAP - OR and parentheses

edited June 2003 in RAP
I am attempting to add a couple AutoSearch criteria using the rap code
interface. Adding the criteria seems easy enough, I use something like
this, on Report.BeforeAutoSearchDialogCreate:

Report.CreateAutoSearchCriteria('Gages', 'Sched Due Date',
soLessThanOrEqualTo,
DateToStr(CurrentDate), False);
Report.CreateAutoSearchCriteria('Gages', 'Use Accumulate', soEqual, '1',
False);

My only question is that I need to add these 2 criteria with an 'OR' between
them, and they need be added within an open/close parentheses (or a
begin...end), when added to other AutoSearchCriteria that is setup on the
Data tab. Can anyone provide a rap code example on how to add a parentheses
and an 'OR' for AutoSearch criteria? Hopefully I have simply overlooked
this in the demos provided.

btw, I would also be curious how this could be done directly from Delphi -
however, this particular problem requires rap code, since the customer does
not want an updated software version. Thanks for any help,

Ben Sykes
bens@indysoft.com
www.indysoft.com

Comments

  • edited June 2003
    Hi Ben,

    Below is an example of how you could add an "OR" or parentheses to a search
    criteria using Delphi code. This, however, will require that you use a
    passthru function to get this working in RAP. See the ReportBuilder
    Developer's Guide for a tutorial on creating RAP passthru functions.

    http://www.digital-metaphors.com/tips/AddSearchCriteria.zip


    - Passthru Function Example:

    http://www.digital-metaphors.com/tips/RapPassThroughBoolean.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2003
    thanks for the Delphi example (we already are using pass through functions -
    they work well), but in this case, I have to add these AutoSearch criteria
    through RAP, since the customer does not want to update the software. Is
    this possible?

    Ben Sykes
    bens@indysoft.com
    www.indysoft.com

  • edited June 2003
    Ben,

    Sorry but unfortunately adding AutoSearch criteria is not possible in RAP
    unless you us a passthru function.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2003
    I guess I should also mention: the only reason we have to do this in RAP
    code, rather than simply using the Data tab's Search page (I know you can
    right mouse click there and add OR's, parentheses, etc.), is that the
    customer wants to add a filter that requests data less than or equal to
    today's date + 7 - and this criteria has to be OR'd with another criteria.
    This is why I was looking at simply creating the AutoSearch condition in RAP
    code. But maybe I should back up and ask if it is possible to accomplish
    this type of 'relative dating' anywhere else in ReportBuilder.

    For instance, I tried to create the search criteria on the Data tab (lets me
    pre-setup the OR, parentheses, etc.), then use the RAP code to change the
    date filter's expression - something like:

    var
    ppTemp : TppAutoSearchField;
    begin
    ppTemp := Report.AutoSearchCriteriaByName('Company', 'Sched Due Date');
    if ppTemp <> nil then ppTemp.Value := (CurrentDate + 7);
    end;

    But this would not work (AutoSearchCriteriaByName was always nil). What
    event would be appropriate for setting this Value? I assume that Value is
    the correct TppAutoSearchField property? Thanks again for the help,

    Ben Sykes
    bens@indysoft.com
    www.indysoft.com

  • edited July 2003
    Ben,

    The TppAutoSearchField.Value property is a read only property so you will
    not be able to assign this value. You will need to create the autosearch
    criteria completely in RAP using the CreateAutoSearchCriteria function. You
    will want to call this function in the Global OnCreate event in the Calc
    workspace. Refer to the TppReport.CreateAutoSearchCriteria documentation in
    the ReportBuilder help for more information.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2003
    Ben,

    Sorry, I just realized that there is a way to set the value of the
    TppAutoSearchField by using the published property SearchExpression. I
    tested this with RAP and it seems to work correctly. Here is the RAP code
    that I used with the DBDEMOS database and the orders table. This code was
    placed inside the GetAutoSearchValues event in the Report object.

    procedure ReportOnGetAutoSearchValues;
    var
    ppTemp: TppAutoSearchField;
    begin
    ppTemp := Report.AutoSearchCriteriaByName('orders', 'SaleDate');

    if ppTemp <> nil then
    ppTemp.SearchExpression := DateToStr(CurrentDate + 7);

    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2003
    Do you have to have some kind of pass-through function already in place to
    get this code to work? Or does it work in RB7 "out of the box"?

    I can't seem to get it to work (don't have any pass-through functions
    defined at all).

  • edited July 2003
    Setting an autosearch field's SearchExpression should work out of the box.
    The property is published so it should be visible in RAP. What doesn't
    compile- which line of code in RAP? If still no joy, feel free to send a
    DBDemos based example to support@digital-metaphors.com that isn't compiling.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited July 2003
    It isn't a question of getting it to compile or not. We integrate RB into
    our larger Case Management application as an end-user reporting solution,
    with stock, but full, RAP capabilities. Trying to set this property in a
    report just has no effect.

    If you're referring to RAP's compiler, it compiles fine. The report runs
    without throwing an error. It just doesn't act like I've changed anything,
    or maybe changed the right thing in the wrong report event. I need to find
    some time to look at it again and I'll get back to you with some more
    specific specifics. :)

This discussion has been closed.