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

Auto Search Field Confirmation

edited October 2003 in General
When using the CreateAutoSearch, how can I confirm that the field
(fFieldName) actually existed and the autosearch was created. I set a value
in the header if the autosearch filter was added so I need to know if it was
successful or not. In some cases, the user may have altered the report and
the autosearch field does not exist. If I can get a false return, then I
can know not to include the search criteria in the header.

ppReport1.CreateAutoSearchCriteria(fTableName, fFieldName, fCondition,
fValue, False)

Thanks,
Bob

Comments

  • edited October 2003
    Hi Bob,

    Check out the ReportBuilder source in the daQueryDataView.pas file. In the
    method TdaQueryDataView.CreateCriteriaForAutoSearchField, you can see some
    code that is similar to what you are going to have to do. Below is the code
    you will have to run on your own as well as extract the sql object to be
    used.

    lFields := TStringList.Create;

    try
    if (SQL.AvailableCriteriaCount = 0) then
    SQL.Resync;

    SQL.AvailableCriteriaList(lFields);

    {set string list entries to field names}
    for liIndex := 0 to lFields.Count - 1 do
    begin
    lField := TdaField(lFields.Objects[liIndex]);

    if (lField is TdaCalculation) then
    lFields[liIndex] := TdaCalculation(lField).CalcFieldAlias
    else
    lFields[liIndex] := lField.FieldName
    end;

    {find corresponding field position}
    liIndex := lFields.IndexOf(aAutoSearchField.FieldName);

    You can then use this to check to see if the autosearch field exists or not
    inside the lFields TStringList.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2003
    On what event do you suggest I run this? I suppost I can just run before I
    ever print / view the report?

    I am running a procedure that clears all autosearch fields.
    Then, based on user parameters entered in a screen, I create auto search
    fields.
    Finally, I build a summary of the search criteria and display it in a label
    in the heading.
    I don't want to display the info in heading if the auto search was
    unsucessful (table & field not available for where clause).

    Should I run the code you suggest to see if the autosearch go created? or
    Would I be better off checking to see if the table / field exist before ever
    creating the auto search field?
    I assume the fields that are part of the table but Not in the selected field
    list are still objects (fields) in the report and available for the sql
    statement?

    Thanks for all of your help. This last issue is the only thing I have left.
    I have completely replaced my prior report designer, 88 reports and user
    interface / integration within 3 weeks of starting. RBuilder is much
    better, I have just struggled a little interfacing to my software but that
    is to be expected.

    Thanks,
    Bob

  • edited October 2003
    I have looked at the sample code and tried to implement it without success.
    If the program creates an auto search field on MyDate field and the MyDate
    field does not exist in the dataset being queried, it still shows up in the
    autosearch field list. However, it is not in the sql statement because it
    would be unsuccessful. I need to know either:
    1. how to access valid dataset fields (available for the where clause) or
    2. how to verify if the autosearch got created and will be part of the sql
    statement

    If you can give me some direct info on how to get those answers, it will be
    appreciated. I can iterate through the autosearch fields but I get them
    successful / or not.

    Thanks,
    Bob

  • edited October 2003
    Hi Bob,

    After a long discussion with another engineer, we concluded that we should
    perhaps take another approach to this issue. I created an example that
    basically shows how you should go about this. You can see in the example
    that we do not use the Report.CreateAutoSearchCriteria method at all. It
    first extracts the SQL object and then adds criteria to it by way of
    AutoSearch (by setting the TppField.AutoSearch := True. We were required to
    make a copy of the DataView's SQL object to ensure both DADE and the preview
    knew about the autosearch update.

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

    --
    Best Regards,

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