Topic: Small Bug?

Hey guys.

On my script to stop repeated fields from saving, i found that if i try to close the form on "cancel" it will just repeat my warning message tha ti wrote earlier, even if the edit box is empty.

Here's the part of the script that i'm talking about:

   if frmclientes.bxcont1cliente.text = '' then
                        begin
                        Cancel := True;
                        ShowMessage('O Campo "Contacto (1)" tem que ser preenchido.');
                        end;

as soon as i click on the button to close the form , the same message: O Campo "Contacto (1)" tem que ser preenchido appears, and it doesn't close the form, i have to use the "x" button on top of the form.
This is a minor inconveniance, but is this a bug or did i do something wrong?

Re: Small Bug?

Hello.


Please insert full script, now I can't see what event you use.

Dmitry.

Re: Small Bug?

i will post it from another smaller section, the bug is the same:

procedure frmtipo_btok_onclick (Sender: string; var Cancel: boolean);

 var
     tipo : String;
     existing_tipo_count : Integer;

begin

tipo := frmtipo.bxtipo.text;

     existing_tipo_count := SQLExecute('SELECT COUNT(tipo) FROM tipo WHERE upper(tipo)=upper("'+tipo+'")');


    if existing_tipo_count <> 0 then
        begin
        ShowMessage('já existe este "Tipo" em duplicado');
        Cancel := True;
        end;

/// this is the part that is giving me trouble, if i press cancel, the message will appear

   if frmtipo.bxtipo.text= '' then
                        begin
                        Cancel := True;
                        ShowMessage('O Campo "Tipo" tem que ser preenchido.');
                        end;

end;

Re: Small Bug?

It's strange, please attach your project.

Dmitry.

Re: Small Bug?

Since this is all in Portuguese let me create an mysql server for you, and make a guide so you can replicate the problem.

Re: Small Bug?

Found the problem!!!

I had the bad habit from copying the OK button to the Cancel Button, i would then change the icon and change the form to "no action" but i forgot that it  also copies the procedure.
So everytime i click on the cancel button i would start the procedure anyway...

Sorryyy