 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Sang Tang Guest
|
Posted: Wed Dec 17, 2003 10:26 am Post subject: get a previous value of a calculated field into a calculated |
|
|
I have two calculated field, a opening and closing field. The opening field
value is retrieve from previous value of closing field. (see my example).
I'am not sure does is possible moving record pointer in OnCalcField event.
my problem is the coding doesn't work, and show a message is 'dataset not in
edit or insert mode'. I've used the disablecontrol function, I assume it
doesn't change the record pointer.... debug result is : if the coding isn't
includes any 'next record' or 'first record' function, the coding will work.
Does any know how to solve it? or has any another solution for me?
thanks
ex:
rec. opening closing
0 100 (this's a hidden record for the
first opening)
1 100 ... 250
2 250 ... 380
:
coding:
procedure OnCalcFields event
begin
tableOpening.AsFloat := getOpeningValue;
end;
function getOpeningValue:Real;
var
ds : TDataSet;
Opening :Real;
bm : TBookmark;
begin
if DataSet.ControlsDisabled then exit;
ds := DataSet;
bm := ds.GetBookmark;
ds.DisableControls; { I've used the disablecontrol }
try
ds.First;
for I := 1 to 1 do
begin
if I = 1 then
Opening := theFirstOpening
else begin
Result := Result + Opening + purchase -Sales; //
closing value
end;
ds.Next;
end;
finally ds.GotoBookmark(bm); ds.FreeBookmark(bm);
ds.ControlsDisabled; end;
end;
end;
thanks
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|