joepezt
asked on
Datanase Edit confirmation
Hello!
I am having some problems confirming my data being processed. I want to confirm before i atempt to edit anything in the table, like "do you want to edit this Record?" if I dont want to, i want to just cancel it away, and exit the fiel.
I tried this way without any luck
procedure TForm1.DBNavigator1Click(S ender: TObject; Button: TNavigateBtn);
begin
if button = nbEdit then
if (MessageDlg('Redigere følgende post?', mtWarning, [mbYES,mbNO], 0) = mrYes) then datamodule2.DataSource1.ed it else exit;
end;
I am having some problems confirming my data being processed. I want to confirm before i atempt to edit anything in the table, like "do you want to edit this Record?" if I dont want to, i want to just cancel it away, and exit the fiel.
I tried this way without any luck
procedure TForm1.DBNavigator1Click(S
begin
if button = nbEdit then
if (MessageDlg('Redigere følgende post?', mtWarning, [mbYES,mbNO], 0) = mrYes) then datamodule2.DataSource1.ed
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you use a DBNAvigator, then you can place the code of jsweby in the BeforeAction-Event of you Navigator.
ASKER
thanx!, but i still need to exit the edit mode after i press no
Right, I think there is some confusion with your use of the word Edit. Are you saying that the table is already in Edit mode, and you are asking for confirmation just before you save the record? If this is the case,then you need:
Case Button of
nbPost: if (MessageDlg('Redigere følgende post?', mtWarning, [mbYES,mbNO], 0) = mrYes) then datamodule2.Table1.Post
Else DataModule2.Table1.Cancel;
nbCancel: DataModule2.Table1.Cancel;
End; {Case}
If what you asked for first time is correct, and the table is not yet in Edit mode, then you do not need to cancel anything because you are not editing or inserting.
J.
Case Button of
nbPost: if (MessageDlg('Redigere følgende post?', mtWarning, [mbYES,mbNO], 0) = mrYes) then datamodule2.Table1.Post
Else DataModule2.Table1.Cancel;
nbCancel: DataModule2.Table1.Cancel;
End; {Case}
If what you asked for first time is correct, and the table is not yet in Edit mode, then you do not need to cancel anything because you are not editing or inserting.
J.
ASKER
I get dataset not in insert or edit mode
Then you haven't put the table into edit mode! Is your user confirmation before an edit or before a post?
ASKER
datasource is autoedit
The AutoEdit property is just incase you start typing into a field without setting it into edit mode. This is generally poor programming, to allow this to happen.
You should make the user press a button (e.g. on the DBNavigator) that forces the data table into Edit mode, then you control whether to Post or Cancel these changes.
If you still want to do it your way then if the user says No, I don't want to makes these changes, simply call "Cancel".
You should make the user press a button (e.g. on the DBNavigator) that forces the data table into Edit mode, then you control whether to Post or Cancel these changes.
If you still want to do it your way then if the user says No, I don't want to makes these changes, simply call "Cancel".
ASKER
sorry, but i forgot all about you :-(
but it worked sort of ;)
but it worked sort of ;)