TDBNavigator lazarus / 16-Databases ---------------------------------------------------------------------- ilniko · 2006-03-24 19:37 Hi all, sorry my ignorance, but I don't know how to stop the execution of a Button Action in a TDBNavigator. I've tried calling the ExecuteCancelAction in the BeforeAction event, but nothing to do. Nik ---------------------------------------------------------------------- matthijs · 2006-03-25 10:02 What do you want to cancel? Actions on the database you should cancel in events of the dataset. So if you are using a TSQLQuery and you want to cancel the posting of data you should do the cancellation in the BeforePost event. ---------------------------------------------------------------------- ilniko · 2006-03-25 10:19 I use a TDbf. So I have to call the ExecuteCancelAction in the BeforePost event of the TDbf, to cancel the post? Or whatelse I have to call to do it? Nik ---------------------------------------------------------------------- matthijs · 2006-03-25 11:50 No, you just call DataSet.Cancel ---------------------------------------------------------------------- ilniko · 2006-03-25 12:34 I've tried your suggest, but it doesn't work. The dataset try however to post data in the dbf. Here's my code: Code: [Select] procedure TFMain.DbfPrevBeforePost(DataSet: TDataSet); begin   if DbfPrev.FieldByName('pdata').AsString = '' then     DataSet.Cancel; end; Posting data with the "pdata" field blank, cause a Key Violation on the table index, and even if the DataSet.Cancel is executed, the error message is shown anyway, so i suppose that the Cancel did not work. ---------------------------------------------------------------------- matthijs · 2006-03-25 14:20 What if you change code to: Code: [Select] procedure TFMain.DbfPrevBeforePost(DataSet: TDataSet); begin   if DbfPrev.FieldByName('pdata').AsString = '' then     DbfPrev.Cancel; end; ---------------------------------------------------------------------- ilniko · 2006-03-25 14:35 I've just tried with DbfPrev.Cancel before of DataSet.Cancel and I obtained the same result: the dataset post data anyway. Maybe there is a problem in the DBNavigator? ---------------------------------------------------------------------- matthijs · 2006-03-25 16:24 No, the DB Navigator got nothing to do with this. All the Navigator does is calling methods from the dataset it is connected to. Is the BeforePost called at all? You could test this by showing a message or something like that. ---------------------------------------------------------------------- ilniko · 2006-03-26 11:33 Yes, I called the BeforePost. Not sure if the Cancel procedure was called, the first thing I do was be put a ShowMessage, and the dialog appear correctly. Maybe then the problem is in the TDbf component, that not process correctly the Cancel procedure. I'm thinking to do a Frame with the buttons Add, Delete, etc, and do from myself the code for Insert, Delete, Post, Cancel, etc.