In my application, there are these data components linked like so:
DBGrid > (DataSource > ADOQuery > ADOConnection)
DBNavigator > (DataSource > ADOQuery > ADOConnection)
Whenever the user selects a different row from the DBGrid, or uses the DBNavigator, the ADOQuery's current record changes. Fine, but when the user makes some changes to the current record, then navigating away from it, the changes made are lost.
I would like to display a confirmation dialogue where the user would need to confirm navigating away from the current record in case there were any changes made. And, when the user clicks 'No' then I would like the application NOT to change the current record.
Where should I insert the code? Which event is it that is fired before user navigates away from the current record and how do I stop the action from continuing?
if anythingChanged then
if messageDlg(...)=mrNo then
ADOQuery.dontChangeCurrentRecord;