1 (edited by reteinformatica 2023-03-20 12:57:36)

Topic: Double error message

Hello everyone and thanks for your interest in my problem: I put a button to delete a record from a tablegrid, then I inserted the instruction that if nothing is selected in the tablegrid it must give me a specific message and in my language (Italian ) with 'messagebox'.
Well, it works but in addition to giving me the error window with the message I have that I put, after this it also gives me the window with the original default error message.
Thanks to all and a greeting.

Post's attachments

Attachment icon Prova.zip 323.74 kb, 85 downloads since 2023-03-20 

Re: Double error message

Caio Fabio,
Try it like this

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
  if  (Form1.TableGrid1.RowCount < 1) or (Form1.TableGrid1.SelectedCount < 1) then
    begin
      messagebox('Devi selezionare un articolo dalla tabella','Selezione richiesta',mb_ok or MB_ICONEXCLAMATION);
      cancel := true;
    end;
end;

Derek.

3 (edited by reteinformatica 2023-03-20 13:48:37)

Re: Double error message

Thanks so much Derek, it works!
I would like to ask you a question if you don't mind: in the other thread in an if condition, you put 'end else'.

procedure frmInserimento_bSalvacontinua_OnAfterClick (Sender: TObject);
begin
  if vaction = 'new' then
    begin
      frmavvio.bInserisci.click;
      frminserimento.edtitolo.setfocus;
    end else frminserimento.close;
end;

What's mean 'end else'? Is it the equivalent of 'else' in Visual Basic? But why 'end else' if there isn't an open 'else'?
Thanks always.