Solved

Keep in dsInsert/dsEdit State

Posted on 1999-01-01
7
1,802 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
Independent Software Vendors: 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 50 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

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…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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