...create a Dataset lookup field at runtime?

Author: invisible

Category: Database

// example: create lookup field (string, size: 50) at runtime

with TStringField.Create(YourDataSet) do
begin
   
FieldName := 'FieldName';
   FieldKind := fkLookup;
   DataSet := YourDataSet;
   Name := DataSet.Name + FieldName;
   KeyFields := 'YourKeyFields';
   LookupDataSet := YourLookupDataSet;
   LookupKeyFields := 'YourLookupKeyFields';
   LookupResultField := 'YourLookupResultField';

   FieldDefs.Add(FieldName, ftString, 50, False);
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base