Board index » delphi » How to work with Internal Calculated Fields?

How to work with Internal Calculated Fields?


2004-02-23 08:37:54 PM
delphi129
Hallo,
I want to index TClientDataSet which index Field is my LookupField. I can
not use index directly so I made InternalCalculated Field.
I have problem, I do not know how to assign values to my InternalCalculated
Field, to be same as values in my LookupField, so I can index.
I tried :
procedure TForm1.cdsMasterCalcFields(DataSet: TDataSet);
begin
if DataSet.State = dsInternalCalc
then begin
DataSet.FieldByName('MyIntCalculeted').AsString :=
DataSet.FieldByName('MyLookupFiled').AsString;
end;
end
But I get all blank in InternalCalculated Field.
Thanks a lot
 
 

Re:How to work with Internal Calculated Fields?

Thanks Dave
You help me as always you do.
"Dave Rowntree" <XXXX@XXXXX.COM>writes
Quote
"Milan Miladinovic" <XXXX@XXXXX.COM>writes:
>I want to index TClientDataSet which index Field is my LookupField. I can
>not use index directly so I made InternalCalculated Field.
>
>I have problem, I do not know how to assign values to my
InternalCalculated
>Field, to be same as values in my LookupField, so I can index.
>
>I tried :
>
>procedure TForm1.cdsMasterCalcFields(DataSet: TDataSet);
>begin
>if DataSet.State = dsInternalCalc
>then begin
>DataSet.FieldByName('MyIntCalculeted').AsString :=
>DataSet.FieldByName('MyLookupFiled').AsString;
>end;
>end
>
>But I get all blank in InternalCalculated Field.

Try this:

procedure TForm1.cdsMAsterCalcFields(DataSet: TDataSet);
begin
DataSet.FieldByName('MyInternalCalculated').Value :=


cdsLookup.Lookup('LookupKeyField',DataSet.FieldByName('KeyField').AsInteger,
'LookupResultField');
Quote
end;

--
Dave Rowntree
 

Re:How to work with Internal Calculated Fields?

Thanks Bill
I'll do it as you say
"Bill Todd (TeamB)" <XXXX@XXXXX.COM>writes
Quote
Use FindKey or Locate to find the value in the lookup ClientDataSet.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)