Subject Re: [IBO] Calculated field
Author Lucas Franzen
James,

james_027 schrieb:
>
> I think the use of calculated field is different than in the BDE or
> IBX. The first time I use the oncalculatefield event I saw the ARow,
> and AField parameters which the BDE/IBX does not have. And when I go
> through the IBO help file it say that ....
>
> "It is very important that the calculations be done in the context of
> the IB_Row parameter which is passed into the event. Otherwise, you
> could be basing calculations for one row using data from another row.
>
> This is possible because IBO handles lots of different row types,
> especially when working with the buffered datasets."
>
> ... that's it. I dont have the idea of how to write the calculation

Imagine you have a query like:

SELECT * FROM CUSTOMER

where you have fields like:
CUST_NAME
CUST_CITY
and in a calculated field NAME_CITY you want to show the name and the
city.


procedure TForm1.QryCalculateField(Sender: TIB_Statement;
ARow: TIB_Row; AField: TIB_Column);
begin
// first check if the current field is the Calculated one
if aField.FieldName = 'NAME_CITY' then
begin
aField.AsString := aRow.ByName ( 'CUST_NAME' ).AsString + ' - ' +
aRow.ByName ( 'CUST_CITY' ).AsString;
end;
end;


HTH

Luc.