Help referencing objects based on Sender object
I am trying to make a generic procedure to reference other objects based
on the Sender object. In this case, a response from a communication
port will determine which table object must be update with a new
filter. I was trying to build the table name and associate it with a
secondary object which could be used to modify the original objects
properties.
I have tried several approaches with this being one where the generic
object code is commented out and a case statement used to accomplish the
desire effects.
Thanks for any help.
=======================================================
procedure TForm_PVS.ReQueryData(Sender: TObject; QueryLoc: String);
var
UnitName: String;
UnitNum: Integer;
FilterText: String;
TableUnit: TObject;
begin
UnitName := (Sender as TComm).Name;
UnitNum := StrToInt(Copy(UnitName, Length(UnitName), 1));
FilterText := '''MFU #'' = ' + QueryLoc;
{ (TableUnit as TTable) := 'Table_UNIT'+IntToStr(UnitNum);
(TableUnit as TTable).Active := False;
(TableUnit as TTable).Filter := FilterText;
(TableUnit as TTable).Active := True; }
case UnitNum of
1: begin
Table_UNIT1.Active := False;
Table_UNIT1.Filter := FilterText;
Table_UNIT1.Active := True;
end;
2: begin
Table_UNIT2.Active := False;
Table_UNIT2.Filter := FilterText;
Table_UNIT2.Active := True;
end;
3: begin
Table_UNIT3.Active := False;
Table_UNIT3.Filter := FilterText;
Table_UNIT3.Active := True;
end;
4: begin
Table_UNIT4.Active := False;
Table_UNIT4.Filter := FilterText;
Table_UNIT4.Active := True;
end;
end;
end;
=======================================================
Rod