Solved

stop DBNavigator from saving changes when going to next record

Posted on 2006-07-10
1
289 Views
Last Modified: 2010-04-05
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?
0
Comment
Question by:ICPooreman
1 Comment
 
LVL 26

Accepted Solution

by:
Russell Libby earned 500 total points
ID: 17073700

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

Regards,
Russell

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

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

end;
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now