Find out if a field is linked or not
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
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
This discussion has been closed.
Comments
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
http://www.digital-metaphors.com
info@digital-metaphors.com