?
Solved

Keep in dsInsert/dsEdit State

Posted on 1999-01-01
7
Medium Priority
?
1,840 Views
Last Modified: 2012-08-14
Hi all,

I want to keep my Dataset in dsInsert/dsEdit mode after one validation fail. Acctually I'm using Cancel to stop the insertion mode but the dataset returns to dsBrowse state and I lost all filled fields. So I need:
If validate then POST
If not validate then return to dsInsert/dsEdit State.

I hope to be clear
regards
Paulo
0
Comment
Question by:sergio_2001
[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
  • 2
7 Comments
 
LVL 1

Expert Comment

by:adeng
ID: 1354121

procedure TForm2.Table1IDValidate(Sender: TField);
begin
     if Table1ID.Value > 50 then
     begin
          ShowMessage('Error !!');
          abort;
     end;
end;

Regards, Adeng
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1354122
hi sergio_2001,

your dataset will be in dsinsert/dsedit mode until you cancel it or your post goes ok.

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    Table1.Post;
  except
    { your error message }
  end;
end;


meikl
0
 

Author Comment

by:sergio_2001
ID: 1354123
Hi,

adeng:
Abort don't do what I want I tried both Abort and Cancel.
Abort returns to dsBrowse state too.

kretzschmar:
I'm doing some validation on the beforePost event so if there are anyone wrong I can't let it post he data.


Any more comments?

Regards
Paulo
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 27

Expert Comment

by:kretzschmar
ID: 1354124
hi sergio_2001,

the abort will stay the table in dsedit/dsinsert mode

procedure TForm1.Button1Click(Sender: TObject);
begin
  Table1.Insert;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  try
    Table1.Post;
  except
    showmessage('Error occured'); {Second message comes up}
  end;
end;

procedure TForm1.Table1BeforePost(DataSet: TDataSet);
begin
  if table1.fieldbyname('KDSTaID').AsInteger < 100 then
  begin
    Showmessage('ID-Error'); {First message comes up}
    Abort;
  end;
end;

meikl
0
 
LVL 1

Accepted Solution

by:
adeng earned 150 total points
ID: 1354125
procedure TForm1.Table1BeforePost(DataSet: TDataSet);
begin
        if Table1ID.Value > 50 then
        begin
                Showmessage('Error');
                Abort; // this will cancel the post process and set the dataset return to dsInsert/dsEdit State.

        end else
               Table1.post;
end;

hope this right. Adeng
0
 
LVL 1

Expert Comment

by:adeng
ID: 1354126
I don't see any wrong with my answer or kretzschmar :
Abort will stop the post process so you can't let it post the wrong data and keep Dataset in dsInsert/dsEdit mode.


procedure TForm1.Table1BeforePost(DataSet: TDataSet);
begin
        if Table1ID.Value > 50 then
        begin
                Showmessage('Error');
                Abort;
        end;
end;

hope this right. Adeng
0
 

Author Comment

by:sergio_2001
ID: 1354127
Hi adend / kretzschmar,

I'll will evaluate again the Abort procedure to grade your points.

Regards
Paulo
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
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