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

CreateAutoSearchCriteria with duplicate field names

edited April 2012 in General
Delphi 7
RB 7
Windows Vista

The issue is I have a query which has two tables connected with an inner
join and both tables have a "Number" field (Order.Number, OrderItem.Number).
Before I run the report I need to create search criteria for both Number
fields, however when I add the code...

Report.CreateAutoSearchCriteria('OrderQuery', 'Number', soEqual, 1, false)

...it always creates the filter for the first Number field (Order.Number),
since it doesn't ask for the table name. Because I am doing this in code I
tried using the CreateAutoSearchField method, where it asked for the table
name, but doesn't ask for the pipeline. I also tried...

aField := Report.CreateAutoSearchCriteria('Order', 'Number',
soEqual, '5', false);

aField.FieldAlias := 'Number (2)';

...but it only changes the description of the filter question in the data
selection question dialog box. I've spent a few days on this problem, have
searched the forums, but have yet to find a solution. Thanks!

Breck

Comments

  • edited April 2012
    Hi Breck,

    Rather than using the CreateAutoSearchCriteria, try using the
    CreateAutoSearchField. This allows you to define a field alias and
    should resolve to identical field names but different field aliases.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2012
    Nico, thanks for your response.

    I tried CreateAutoSearchField, but it didn't appear to filter based on the
    field in the query. I was wondering if it has to do with the fact that when
    using CreateAutoSearchField you don't specify a pipeline/query? So how does
    CreateAutoSearchField know which pipeline/query to use?

    Were you able to test this and make it work on your end? Since what I am
    doing is sort of out of the ordinary I wonder if it has been tested or tried
    before.

    Thanks,
    Breck

  • edited April 2012
    ReportBuilder has evolved a long way since RB 7.x.

    I recommend upgrading to ReportBuilder 14.

    RB 14 includes a TdaSQLBuilder class that provides an easy to use run-time
    interface for dynamically modifying the TdaSQL associated with a SQL
    DataView. (TdaSQLBulder was introduced in RB 9). TdaSQLBuilder can be used
    to easily add autosearch critera. It enables you do via code the same things
    you can do via the visual query designer tools.

    From the RBuilder help topic for TdaSQLBuilder...

    ReportBuilder's Data workspace provides visual query designer tools that
    enable design-time modification of DADE SQL DataViews. Use TdaSQLBuilder to
    modify DADE SQL programmatically at run-time. Modification of SQL should be
    performed from the Report.OnInitializeParameters or
    Report.BeforeOpenDataPipelines events.

    RB 14 can open and run your existing reports and includes support for D7 as
    well as the latest Delphi versions. Going forward I also recommend upgrading
    to the Delphi XE2, Delphi has evolved a long way since D7.

    Here is a link to What's New by RB version..

    http://www.digital-metaphors.com/rbWiki/General/What's_New



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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2012
    Thanks Nard. We have purchased both, just have yet to make the jump.

    I did some more searching on the web and found this link between DM and a
    user:
    http://codenewsfast.com/cnf/article/632096/waArticleBookmark.3489428

    I'm assuming if I can access the SQL directly than I can make the changes
    necessary to access the second field.

    Thanks again,
    Breck


This discussion has been closed.