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

Find out if a field is linked or not

edited September 2001 in General
Hi all,

I want to discover for a given AutoSearchField if it is linked to another
field as part of a join in the corresponding dataview and if so what that
field is. Can this be done and if so how?

TIA.
John.

--
I don't like spammers so send your spam to
abuse@hotmail.com

Comments

  • edited September 2001
    Extract the SQL object out of the dataview:

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

    Then check the table join objects in the SelectTables property:

    uses
    daSQL;

    function TForm1.IsThisAJoinField(aReport: TppReport; aAutoSearchField:
    TppAutoSearchField): Boolean;
    var
    lsFieldName: String;
    liIndex: Integer;
    lSQL: TdaSQL;
    lTable: TdaTable;
    liIndex2: Integer;
    lTableJoin: TdaTableJoin;
    begin

    Result := False;

    lsFieldName := Report.AutoSearchFields[0].FieldName;
    liIndex := 0;

    lSQL := ExtractSQLObject;

    while not(Result) and (liIndex < lSQL.SelectTableCount) do
    begin

    lTable := lSQL.SelectTables[liIndex];
    liIndex2 := 0;

    while not(Result) and (liIndex2 < lTable.TableJoinCount ) do
    begin
    lTableJoin := lTable.TableJoins[liIndex2];

    if CompareText((lTableJoin.LocalField.SQLFieldName, lsFieldName)
    = 0) then
    Result := True

    else if CompareText((lTableJoin.ForeignField.SQLFieldName,
    lsFieldName) = 0) then
    Result := True

    Inc(liIndex2);
    end;

    Inc(lindex);
    end;

    end;

    I've just roughed this code out; check daSQL.pas for more on the classes
    involved...

    Cheers,

    --
    -
    --
    Tom Ollar
    Digital Metaphors Corporation
  • edited September 2001
    Thanks Tom. Got that to work OK.
This discussion has been closed.