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

Adding filter conditions at runtime

edited October 2002 in DADE
Hi there, Im using RB7 Ent with D6 Ent.

Before printing a report I would like to attach a set of Filter Condtions to
a report. The filter conditions have been generated by a different part of
the system.

The filters are Where clauses that refer to fields that exist in the
datapipelines for the report.

This route is only going to be used when executing a report so I dont mind
if I have to set EditSQLAsText to true. I wont be seeing the Data tab so I
dont care that I loose some of the data definition features.

Where and when is the best place for me to append the additional where
clauses?

Cheers,
Ben

Comments

  • edited October 2002
    You don't have to edit the SQL text. You can define search criteria on the
    fly. They can be autosearch or not. Autosearch means that you can specify
    search criteria values. If there are no search criteria defined in the
    dataviews when you print the report, then you can create them dynamically
    before the report runs. The criteria can be saved down as part of the
    template at that point, or you can always create them. You can create them
    as shown in the demo link below. This demo shows how to modify the where
    clause without using autosearch. To take it one step further, you can
    specify them as autosearch criteria and use autosearch as shown in the
    Autosearch demos in the installation. There is one demo which shows how to
    set the value for end user search criteria.

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


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited November 2002
    To continue . . .

    I now have some code which adds a Criteria Field at runtime. Where / When is
    the best place to call this code? Before Print does not seem to work. Or
    after addding the Criteria Fields, is there something I can call to force
    them to take effect?

    Also, does each "DataSet" defined in DADE have its own TdaSQL object??

    If so, am I correct in assuming that I first have to locate the correct
    DataView and then add specific Criteria to that object?

    Cheers,
    Ben



  • edited November 2002
    If you want to add some criteria objects, then you can use the
    Report.Template.OnLoadEnd event. It should work also in the
    Report.BeforePrint event, because this is the timing that I use regularly
    when adding DADE objects. First, make sure that the event handler is
    getting called. See the Templates thread in the Tech-Tips newsgroup on lost
    event handlers.

    You're right, you need to search to find the dataview. Which dataview do
    you need to find? You can search by datapipeline name, or look through the
    TdaSQL object's to find a particular table and field with a criteria that
    you want to add. If you know it is on the master then you can compare the
    datapipeline name to the report's name in your event handler. Here is an
    example which locates a datapipeline in a dataview by name:

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


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.