Page 1 of 1

Question for query.modified

Posted: Tue 24 Jul 2007 12:20
by shsit
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

Posted: Wed 25 Jul 2007 07:01
by Antaeus
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;