Subject | Re: [IBO] What's the best way to calculate a field in TIB_Grid? |
---|---|
Author | Jörg Schiemann |
Post date | 2000-12-08T07:41:26Z |
The Solution I found is to use calcualtedFields and call the UpdateRecord
and CalculateFields method to manually invoke them when the specific
columns changes.
Here's my code. But my mind is always open for a better solution. :-)
procedure TfrmAuftragBearbeiten.gridFFirmaColExit(Sender: TObject);
begin
if gridFFirma.Col in [4..6] then begin
qryFremdFirmen.UpdateRecord;
qryFremdFirmen.Fields.CalculateFields ;
end; {if}
end;
Regards, Jörg
and CalculateFields method to manually invoke them when the specific
columns changes.
Here's my code. But my mind is always open for a better solution. :-)
procedure TfrmAuftragBearbeiten.gridFFirmaColExit(Sender: TObject);
begin
if gridFFirma.Col in [4..6] then begin
qryFremdFirmen.UpdateRecord;
qryFremdFirmen.Fields.CalculateFields ;
end; {if}
end;
Regards, Jörg
> A friend mine wrote specific code to detect when a field loses focus, sothe
> code was tied to the GUI. He had to make sure no field involved was NULL,field
> empty, etc., and called CalculateFields that makes possible to force the
> event for calculated fields to trigger immediately.
>
> C.
>
> > -----Original Message-----
> > From: Jörg Schiemann [mailto:schimmi@...]
> > Sent: Sábado 2 de Diciembre de 2000 15:16
> >
> > Hi,
> >
> > what's the best way to calculate a field in TIB_Grid?
> >
> > I tested with
> >
> > CREATE TABLE t_test
> > (
> > QUANTITY INTEGER;
> > HOURLY_WAGGE NUMERIC(18,2);
> > COST COMPUTED BY (QUANTITY * HOURLY_WAGGE)
> > );
> >
> > but it doesn't update the field in the grid.
> >
> > I also tested another way with CalculateFields in TIB_Query
> >
> > procedure TfrmJob.qryJobCalculateField(
> > Sender: TIB_Statement; ARow: TIB_Row; AField: TIB_Column);
> > begin
> > with AField do
> > if FieldName = 'COST' then
> > AsDouble := ARow.ByName('QUANTITY').AsInteger +
> > ARow.ByName('HOURLY_WAGGE').AsDouble;
> > end;
> >
> > that way the field gets updated, but first when you post the changes.
> >
> > I'm looking for a function which updates the field directly when the
> > QUANTITY or HOURLY_WAGGE lost the focus.
> >
> > TIA
> >
> > Jörg Schiemann
>
>
>
>
>
>