Create a Dataset lookup field at runtime

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;