• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

stop DBNavigator from saving changes when going to next record

I have a bunch of DBeditboxes that are in edit mode and a DBNavigator which navigates through all of my records.  I only want my user to be able to change a record by clicking a specific button.  I have that part working when you click the button I just post the data then put the form back into edit mode.  

My problem is if you edit one of the edit boxes and then go to the next record it appears to be saving your changes in the database.  This is a very unwanted behavior any idea on how I can stop that from happening?
1 Solution
Russell LibbySoftware Engineer, Advisory Commented:

You can catch the BeforeAction of the navigator control and cancel the edit mode before moving to another record, eg:


procedure TForm1.DBNavigator1BeforeAction(Sender: TObject; Button: TNavigateBtn);

  with TDBNavigator(Sender) do
     if Assigned(DataSource) and (Button in [nbFirst, nbPrior, nbNext, nbLast]) and (DataSource.State in [dsEdit, dsInsert]) then

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now