Topic: Form validations

Hello guys, i need some help.
I have 2 questions.

1st - I have a form that i can add clients, i have some textbox where i can put name, age, etc.
When i find the clients and open the form "edit" the texboxes are filled with the name of the selected client.
When i open the form add a new client the textboxes are filled with the name of the client i eddit.
There is a way to force them to be cleared?

2nd - The form addClient i can text some data, like name, age, etc. but i want some fields not null i have a piece of code but is not working...
What am i doing wrong ??

procedure frmNewClient_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
      if (frmNewClient.cboxNome.Text = "" )then
             MessageDlg('O campo "Nome" é obrigatório.',mtError,mbOK,0);
             Cancel := True;
          end;

end;

I would appreciate some help

Re: Form validations

1. For add new a client, you should use button with action "NewRecord" instead "ShowForm"


2. try this

procedure frmNewClient_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
      if frmNewClient.cboxNome.Text = '' then
      begin      
          MessageDlg('O campo "Nome" é obrigatório.',mtError,mbOK,0);
          Cancel := True;
      end;
end;
Dmitry.

Re: Form validations

Hellow Dmitry, thanks for the fast reply.

For the form client it worked my mistake when i select "showForm" instead of "newRecord"

I tried the conde and it works but it dont show the message i want.. hmm


Another question, can we disable the double click on a tablegrid?
So we are forced to select the row on the table and then click a button for the specifyed action??

Re: Form validations

ailinux wrote:

I tried the conde and it works but it dont show the message i want.. hmm

You can send me project to support@drive-software.com
I'll check it.

ailinux wrote:

Another question, can we disable the double click on a tablegrid?

Form1.TableGrid1.dbPopupMenu.Items.Items[0].Enabled := False;
ailinux wrote:

So we are forced to select the row on the table and then click a button for the specifyed action??

Yes.

procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
    Form1.TableGrid1.SelectedRow := 0; // select first row
    Form1.Button2.Click;
end;
Dmitry.