?
Solved

Check if modified

Posted on 2003-03-19
5
Medium Priority
?
205 Views
Last Modified: 2010-04-04
How is it possible to check before i close a form if something has been modified since the last time user saved the content?
And how can i check if the content was opened or if it was not?

i have on my form edits, datetimepicker, dbgrid...
contents are saved to db:s and files.
0
Comment
Question by:tscooter82
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:mocarts
ID: 8167972
use TDataSet's BeforePost event:

type
  TForm1 = class(TForm)
  ..
    procedure Table1BeforePost(DataSet: TDataSet);
  ...
  private
    FModified: boolean;
  end;

implementation

procedure TForm1.Table1BeforePost(DataSet: TDataSet);
begin
  if not FModified then
    FModified := DataSet.Modified;
end;

in form's close check FModified field..
wbr, mo.
0
 

Author Comment

by:tscooter82
ID: 8174343
ok, but how for the other componets? (edits, datetimepickers)
0
 
LVL 9

Accepted Solution

by:
mocarts earned 75 total points
ID: 8174421
if these are dbedits attached to dataset then code above will work as well. if you are talking about TCustmoEdit descendant then you can use Modified property.
for dateTimePicker's you must provide event handler for onChange event:
procedure TForm1.datetimepicker1Change(Sender: TObject);
begin
  FModified := True;
end;

in close event:
...
if FModified or Edit1.Modified or Edit2.Modified then
  ShowMessage('Changes are made. Will save.');
...

wbr, mo.
0
 

Author Comment

by:tscooter82
ID: 8182587
ok, thx.
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8182662
not at all :)
25pt and grade B - you can count on me ;D
wbr, mo.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

621 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