User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 391,782 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,579 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:

OnCalcField modifying its own DataSet - Error

Join Date: Nov 2007
Posts: 22
Reputation: ecostas is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
ecostas ecostas is offline Offline
Newbie Poster

Re: OnCalcField modifying its own DataSet - Error

  #2  
May 6th, 2008
Hi. If you are using ClientDatasets, maybe you can try RecNo and Recordcount to find out if you are in the last record. But from your code I can' t understand why you need it. Maybe that's not exactly your code. Haven't tried my solution, to be honest.

Eduardo

Originally Posted by MoZo1 View Post
Well... I could copy the data, and use that, but that would be very slow, and I would have to copy often and a lot. I have a table where records depends on another one. Still, it will be the backup if I can't solve this.
So every time I try to move the active record from inside the OnCalcField event I get a lot of some veird EOleException invalid argument error, even when I don't even read or write any data. I know, I must restore the dataset at the end of the event, as I do every time before EnableControls.

This is my event:
  1. procedure TForm1.calc(DataSet: TDataSet);
  2. begin
  3. try
  4. Dataset.FieldByName('Calc').AsInteger:=10;
  5. if qwe then exit;
  6. qwe:=true;
  7. dataset.DisableControls;
  8. //dataset.next;
  9. //if not dataset.Eof then dataset.prior;
  10. dataset.EnableControls;
  11. ListBox1.AddItem(Dataset.FieldByName('SampleNum').AsString,nil);
  12. qwe:=false;
  13. except
  14. showmessage('This never shows!');
  15. ADOQuery1.OnCalcFields:=nil;
  16. end;
  17. end;
When I try to uncomment the 2 lines it throws the errors, but I can't even catch it. If something handles the error, it couldn't become recursive because qwe prevents it. And I've already tryed with GotoBookmark and First, in case eof would cause this, but it's the same.

Also I can't find anything on google, so it would be nice if somebody could only show me a working example.
Thanks!
Reply With Quote  
All times are GMT -4. The time now is 5:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC