I'm using Dephi 10.1 Berlin and Access 2013.
My problem is related to TADODataSet.Cancel()
.
I want to show my user a message box asking for a confirmation before posting, in case data has been modified.
In the TADODataSet.BeforePost
event, I added the following code:
if Application.MessageBox('Save changes?', '', 52) = idNo then
ADODataSet1.Cancel;
If the user click on btnNo
, something unexpected happens.
Changes are canceled from the current record, but a new record with all fields empty is created.
The only field with some data is the one that was previously modified by the user.
If I cancel the modification via the cancel button of TDBNavigator
, everything is fine.
If I simulate a click of the Cancel button of the TDBNnavigator
in the BeforePost
event:
if Application.MessageBox('Save changes?', '', 52) = idNo then
DBNavigator1.BtnClick(nbCancel);
I have the same behaviour, so a new empty record is created.
Any suggestion?