Subject | order by with a calculated field |
---|---|
Author | bwc3068 |
Post date | 2009-06-26T19:22:38Z |
hi--
i've got a query that has a persistent field in it called: OwnerName. it's a calculated field.
It's in the equipment query/table that holds all the equipment and one of the other fields in the equipment query is the uniquekey of the owner in the owner table.
as you can guess, the calculated field OwnerName uses the equipment table's owner-table uniquekey to look up the owner name in the owner table.
when i try and sort by OwnerName, I get an error. Can I sort by the calculated field when it's persistent like that (I'm pretty sure i could sort by the calculated field if it was something like: order by (count(employees)). that is, something calculated right there in the order by clause.
this is the .OnGetText of the calculated field:
procedure TdmMain.OwnerNameGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
with wqryTemp do begin
active := False;
sql.clear;
sql.add('select OwnerName, UniqueKey from Owners where UniqueKey ='+quotedstr(sEquipmentTablesOwnerUniqueKey));
try
active := True;
sCurrentOwnerName := FieldByName('OwnerName').text;
active := False;
except
end;
end;
text := sCurrentOwnerName;
end;
thoughts?
thanks
kelly
i've got a query that has a persistent field in it called: OwnerName. it's a calculated field.
It's in the equipment query/table that holds all the equipment and one of the other fields in the equipment query is the uniquekey of the owner in the owner table.
as you can guess, the calculated field OwnerName uses the equipment table's owner-table uniquekey to look up the owner name in the owner table.
when i try and sort by OwnerName, I get an error. Can I sort by the calculated field when it's persistent like that (I'm pretty sure i could sort by the calculated field if it was something like: order by (count(employees)). that is, something calculated right there in the order by clause.
this is the .OnGetText of the calculated field:
procedure TdmMain.OwnerNameGetText(Sender: TField;
var Text: String; DisplayText: Boolean);
begin
with wqryTemp do begin
active := False;
sql.clear;
sql.add('select OwnerName, UniqueKey from Owners where UniqueKey ='+quotedstr(sEquipmentTablesOwnerUniqueKey));
try
active := True;
sCurrentOwnerName := FieldByName('OwnerName').text;
active := False;
except
end;
end;
text := sCurrentOwnerName;
end;
thoughts?
thanks
kelly