Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Keep in dsInsert/dsEdit State

Posted on 1999-01-01
7
Medium Priority
?
1,862 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
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

610 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