BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

get a previous value of a calculated field into a calculated

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Sang Tang
Guest





PostPosted: Wed Dec 17, 2003 10:26 am    Post subject: get a previous value of a calculated field into a calculated Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.