Question for query.modified

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
shsit
Posts: 21
Joined: Thu 05 Oct 2006 11:41

Question for query.modified

Post by shsit » Tue 24 Jul 2007 12:20

Hi there!

On my onCloseQuery events I check MyQuery1.modified and show the user and dialog box that asks for saving, if he made changes on this form.

My Problem:
If I make changes in EditField1, and then goto EditField2, MyQuery1.modified is true.
But if I make changes only in EditField1 and don't leave the EditField1 , MyQuery1.modified is false altough the data in EditField1 was altered.

Is there a way to solve this?

Thank you very much,
greets ben

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 25 Jul 2007 07:01

A new field value is not passed to dataset until you edit the value in TDBEdit. When you exit from TDBEdit, it passes the new value to the underlying dataset, and the dataset becomes modified. So this is a designed behaviour of standard VCL classes. You can do something like this:

Code: Select all

  if MyQuery.Modified then
    Modified := True
  else 
    if Form1.ActiveControl is TDBEdit then
      Modified := TDBEdit(Form1.ActiveControl).Modified;

Post Reply