?
Solved

Datanase Edit confirmation

Posted on 2002-03-25
9
Medium Priority
?
185 Views
Last Modified: 2010-04-04
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(Sender: TObject; Button: TNavigateBtn);
begin
 if button = nbEdit then
 if (MessageDlg('Redigere følgende post?', mtWarning, [mbYES,mbNO], 0) = mrYes) then datamodule2.DataSource1.edit else exit;
end;
0
Comment
Question by:joepezt
[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
  • 4
  • 4
9 Comments
 
LVL 4

Accepted Solution

by:
jsweby earned 60 total points
ID: 6894244
You don't want to edit the DataSource, you want to edit the Table or Query that the Datasource points to, therefore:

if button = nbEdit then
if (MessageDlg('Redigere følgende post?', mtWarning, [mbYES,mbNO], 0) = mrYes) then datamodule2.Table1.edit
else exit;

or better still:

Case Button of
  nbEdit: if (MessageDlg('Redigere følgende post?', mtWarning, [mbYES,mbNO], 0) = mrYes) then datamodule2.Table1.edit;
End; {Case}

J.
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 6895736
If you use a DBNAvigator, then you can place the code of jsweby in the BeforeAction-Event of you Navigator.
0
 
LVL 2

Author Comment

by:joepezt
ID: 6896445
thanx!, but i still need to exit the edit mode after i press no
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 4

Expert Comment

by:jsweby
ID: 6896476
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.
0
 
LVL 2

Author Comment

by:joepezt
ID: 6899108
I get dataset not in insert or edit mode
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6899221
Then you haven't put the table into edit mode! Is your user confirmation before an edit or before a post?
0
 
LVL 2

Author Comment

by:joepezt
ID: 6899556
datasource is autoedit
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6899569
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".
0
 
LVL 2

Author Comment

by:joepezt
ID: 7083315
sorry, but i forgot all about you :-(
but it worked sort of ;)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 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