Subject | Re: [IBO] Help :OnValidate |
---|---|
Author | teo miljko |
Post date | 2001-04-02T15:43:22Z |
I have query tdetail and dbgrid ib_grid2.
In Ib_grid2 I have :
// I use tdetail.tag as flag so that I know which field is entered from
keyboard
procedure Tfrmprimkafin.IB_Grid2CellGainFocus(Sender: TObject; ACol,
ARow: Integer);
begin
inherited;
if tdetail.fields[ib_grid2.gridcol[acol]].fieldname='POREZ_P' then
tdetail.tag:=0;
if tdetail.fields[ib_grid2.gridcol[acol]].fieldname='POREZ' then
tdetail.tag:=2;
end;
in Tdetail.OnValidate I have:
// without tdetail.tag as flag I will have loop and value
arow.byname('POREZ').ascurrency wil be
// changed by arow.byname('POREZ_P').ascurrency even if I entered it
manually
if (afield.fieldname='POREZ_P') and (tdetail.tag=0)
then begin
arow.byname('POREZ').ascurrency:=
( arow.byname('NABAVA').ascurrency+
arow.byname('CARINA').ascurrency)*
arow.byname('POREZ_P').ascurrency/100;
tdetail.tag:=1;
end;
if (afield.fieldname='POREZ') and (tdetail.tag=2)
then begin
tdetail.tag:=1;
arow.byname('POREZ_P').ascurrency:=
arow.byname('POREZ').ascurrency/
( arow.byname('NABAVA').ascurrency+
arow.byname('CARINA').ascurrency) *100;
end;
It works in edit state.I'm looking for best solution.
Thanx, Teo
In Ib_grid2 I have :
// I use tdetail.tag as flag so that I know which field is entered from
keyboard
procedure Tfrmprimkafin.IB_Grid2CellGainFocus(Sender: TObject; ACol,
ARow: Integer);
begin
inherited;
if tdetail.fields[ib_grid2.gridcol[acol]].fieldname='POREZ_P' then
tdetail.tag:=0;
if tdetail.fields[ib_grid2.gridcol[acol]].fieldname='POREZ' then
tdetail.tag:=2;
end;
in Tdetail.OnValidate I have:
// without tdetail.tag as flag I will have loop and value
arow.byname('POREZ').ascurrency wil be
// changed by arow.byname('POREZ_P').ascurrency even if I entered it
manually
if (afield.fieldname='POREZ_P') and (tdetail.tag=0)
then begin
arow.byname('POREZ').ascurrency:=
( arow.byname('NABAVA').ascurrency+
arow.byname('CARINA').ascurrency)*
arow.byname('POREZ_P').ascurrency/100;
tdetail.tag:=1;
end;
if (afield.fieldname='POREZ') and (tdetail.tag=2)
then begin
tdetail.tag:=1;
arow.byname('POREZ_P').ascurrency:=
arow.byname('POREZ').ascurrency/
( arow.byname('NABAVA').ascurrency+
arow.byname('CARINA').ascurrency) *100;
end;
It works in edit state.I'm looking for best solution.
Thanx, Teo
----- Original Message -----
From: Claudio Valderrama C. <cvalde@...>
To: <IBObjects@yahoogroups.com>
Sent: Monday, April 02, 2001 8:46 AM
Subject: RE: [IBO] Help :OnValidate
> Then I don't have any idea what you want. In the OnValidate event you
> shouldn't change field values. The BeforePost event is just before the row
> is sent to the server, be it insert, delete or update. You can change
values
> here. Isn't it what you wanted? You have PostedState built-in variable to
> know if the operation is Insert, Delete or Update.
>
> C.