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

Is it a bug in TppReport.AutoSearchCriteriaByName in RB6.02

edited November 2001 in General
function TppReport.AutoSearchCriteriaByName(const aDataPipelineName,
aFieldName: String): TppAutoSearchField;
......

if (CompareText(aDataPipelineName, lAutoSearchField.DataPipelineName) = 0)
or (CompareText(aFieldName, lAutoSearchField.FieldName) = 0) then
..........

Should use 'And' not 'Or' because if I have 2 dataview in one datamodule and
both dataview has autosearch field.fieldName = 'MyField', then this Function
always return the first AutoSearchField.

I hope this can be fixed in the next version.

Tao

Comments

  • edited November 2001
    Yep, that would be bad. It has been fixed for the next release. I can send
    you the patch files if you would like and you can recompile using your
    ..\RBuilder\Source\.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited November 2001
    Thanks, I will fix the bug by myself.

    Tao

  • edited November 2001
    Also in daQueryDataview.pas you need to add one line in this method:

    {---------------------------------------------------------------------------
    ---}
    { TdaQueryDataView.CreateAutoSearchFields }

    procedure TdaQueryDataView.CreateAutoSearchFields(aReport: TppReport);
    var
    liIndex: Integer;
    lCriteria: TdaCriteria;
    lField: TppAutoSearchField;
    begin

    for liIndex := 0 to FSQL.CriteriaCount - 1 do
    begin
    lCriteria := FSQL.Criteria[liIndex];

    if (lCriteria.Field <> nil) and (lCriteria.Field.AutoSearch) then
    begin
    lField := TppAutoSearchField.Create(Self);

    if (lCriteria.IsExpression) then
    lField.FieldAlias := lCriteria.Expression
    else
    lField.FieldAlias := lCriteria.Field.Alias;

    lField.DataPipelineName := GetDataPipelineForIndex(0).Name; <---
    add this line:)
    lField.FieldName := lCriteria.Field.FieldName;
    lField.DataType := lCriteria.Field.DataType;
    lField.SearchExpression := lCriteria.Value;
    lField.SearchOperator :=
    daOperatorToppOperator(lCriteria.Operator);
    lField.ShowAllValues := lCriteria.Field.ShowAllValues;
    lField.Mandatory := lCriteria.Field.Mandatory;
    lField.TableAlias := lCriteria.Field.TableAlias;
    lField.TableName := lCriteria.Field.TableName;

    {save a pointer to the corresponding criteria and dataview}
    lField.Criteria := lCriteria;
    lField.DataView := Self;
    lField.OnChange := AutoSearchFieldChangeEvent;

    lField.Parent := aReport;

    {establish a free notification relationship}
    FLinkedAutoSearchFields.Add(lField);
    lField.AddNotify(Self);

    end;

    end;

    end; {procedure, CreateAutoSearchFields}



    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.