?
Solved

Check if modified

Posted on 2003-03-19
5
Medium Priority
?
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

764 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