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 402,955 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 2,901 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: Programming Forums
Views: 1289 | Replies: 12
Join Date: Mar 2008
Posts: 13
Reputation: MoZo1 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
MoZo1 MoZo1 is offline Offline
Newbie Poster

OnCalcField modifying its own DataSet - Error

  #1  
May 6th, 2008
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!
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Pascal and Delphi Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 6:43 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC