Solved

stop DBNavigator from saving changes when going to next record

Posted on 2006-07-10
1
293 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 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