Solved

Keep in dsInsert/dsEdit State

Posted on 1999-01-01
7
1,752 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
  • 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now