Solved

Keep in dsInsert/dsEdit State

Posted on 1999-01-01
7
1,822 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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

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