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

Passing Autosearch Dates to multiple datasets via CreateAutoSearchCriteria

edited October 2004 in End User
I am using Delphi 7.1 with RB 7.04.

I am trying to have an end user report that returns totals for a selected
period and also returns totals for the previous period. I am trying to use
the CreateAutoSearchCriteria method.

Is this possible? Is this the correct method? Is there a better event?

Please keep in mind this is all done in the end user explorer.

Here is what I have so far...

procedure ReportBeforePrint;
var
TempValue : TppAutoSearchField;
begin
TempValue := Report.AutoSearchCriteriaByName('Filters', 'APPTSTART');

GlobalDateStart := TempValue.Values[0];
GlobalDateStop := TempValue.Values[1];

GlobalPreviousDateStop := GlobalDateStart - 1;
GlobalPreviousDateStart := GlobalPreviousDateStop - (GlobalDateStop -
GlobalDateStart) + 1;

Report.CreateAutoSearchCriteria('PreviousAppt', 'APPTSTART', soBetween,
DateToStr(GlobalPreviousDateStart) + ', ' +
DateToStr(GlobalPreviousDateStop) + ' 23:59:59', True);
end;

Any comments or suggestions would be great.

Comments

  • edited October 2004
    Hi Issac,

    You will need to create a pass thru function in order to access the datasets
    created in DADE. The example below shows how you can go about doing this
    using the OnGetAutoSearchValues event in RAP. Note that this example
    changes the Autosearch criteria using a Report Parameter defined before the
    app is executed.

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

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2004
    Hi Nico,

    That worked great. There is only one small quirk left. If the user previews
    the report then changes their report options, criteria keeps getting added
    to the query which brings back overfiltered results.

    Is there a way to remove that newly added criteria before the Autosearch
    form is displayed again?

  • edited October 2004
    Hi Isaac,

    I would suggest creating another passthru function that clears out the
    autosearch fields currently in your report, except the empty one at the
    beginning of the list that is keeping the GetAutoSearchValues event firing.
    Try using the TdaSQL.RemoveCriteria method.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2004
    Is there a way I can tell which ones where added by the designer versus RAP
    code?

  • edited October 2004
    Hi Issac,

    Unfortunately no, the criteria added using the RAP passthru function is done
    exactly the same way the designer does it. In fact the code is almost
    copied. You will probably need to keep track somehow of the index number of
    the search criteria you add to the list and locate them this way.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2004
    I added a function to remove the criteria one at a time based on the table
    and field names.

    Thanks. That worked great.

This discussion has been closed.