Board index » delphi » MessageDlg Undeclared Identifier

MessageDlg Undeclared Identifier

Trying to bring up a MessageDlg before closing table. Compiler error;
Undeclared Identifier: 'mbYesNo'.
How and where should I make this declaration?
I'm a newbie, so a code snippet/small example will explain better.
Thanks, Paul.
==============================================================
procedure TForm2.Table1BeforeClose(DataSet: TDataSet);
begin
if (Table1.State = dsEdit) or (Table1.State = dsInsert) then
 begin
   if MessageDlg('Post changes before closing?', mtConfirmation, mbYesNo,
0) = mrYes then
     Table1.Post
   else
     Table1.Cancel;
 end;
end;
===============================================================

 

Re:MessageDlg Undeclared Identifier


Quote
Paul wrote:

> Trying to bring up a MessageDlg before closing table. Compiler error;
> Undeclared Identifier: 'mbYesNo'.
> How and where should I make this declaration?
> I'm a newbie, so a code snippet/small example will explain better.
> Thanks, Paul.
> ==============================================================
> procedure TForm2.Table1BeforeClose(DataSet: TDataSet);
> begin
> if (Table1.State = dsEdit) or (Table1.State = dsInsert) then
>  begin
>    if MessageDlg('Post changes before closing?', mtConfirmation, mbYesNo,
> 0) = mrYes then
>      Table1.Post
>    else
>      Table1.Cancel;
>  end;
> end;
> ===============================================================

Did you add "Dialogs" to your uses statement?

Rkr
--

          \|||/
          /'^'\
         ( 0 0 )
-----oOOO--(_)--OOOo----------
Reid Roman
E-Mail : rkroman (at) pacbell (dot) net
Delphi Enthusiast, Hobbyist ..
TVisualBasic:=class(None);
U.S.A
------------------------------

Re:MessageDlg Undeclared Identifier


On 21 Nov 97 13:54:37 GMT, "Paul " <p...@bigpond.com> wrote:

Quote
>Trying to bring up a MessageDlg before closing table. Compiler error;
>Undeclared Identifier: 'mbYesNo'.
>How and where should I make this declaration?
>I'm a newbie, so a code snippet/small example will explain better.
>Thanks, Paul.
>==============================================================
>procedure TForm2.Table1BeforeClose(DataSet: TDataSet);
>begin
>if (Table1.State = dsEdit) or (Table1.State = dsInsert) then
> begin
>   if MessageDlg('Post changes before closing?', mtConfirmation, mbYesNo,
>0) = mrYes then
>     Table1.Post
>   else
>     Table1.Cancel;
> end;
>end;
>===============================================================

Paul,

This is one of those subtle syntax problems. The third parameter in a
messagedlg must be an array. There are some predefined arrays such as
mbYesNoCancel, which are put in without brackets. You need something
other than a predefined array, so put them in as an array:
(...mtConfirmation, [mbYes, mbNo], 0)
Even if you want only one button, it must be in [brackets].

Dan
CMDC systems
Configuration Management and Document Control Consultants
Software and Training

Re:MessageDlg Undeclared Identifier


You must enclose mbYesNo in brackets [mbYesNo]

Bill

Quote
> > Trying to bring up a MessageDlg before closing table. Compiler error;
> > Undeclared Identifier: 'mbYesNo'.
> > How and where should I make this declaration?
> > I'm a newbie, so a code snippet/small example will explain better.
> > Thanks, Paul.
> > =============================================================

Other Threads