3

Why this code is not working:

procedure TFormNotification.Button3Click(Sender: TObject);
begin
  FormB.Show;
end;

I'm getting Undeclared identifier error.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
emurad
  • 3,448
  • 10
  • 40
  • 47

2 Answers2

11

You probably have a global variable named FormB declared in the interface section of a unit named UnitB. But UnitA doesn't know anything about that unit or its contents. In particular, it doesn't know what the word FormB means — that identifier is undeclared.

To tell UnitA about the things declared in UnitB, add UnitB to the uses clause in UnitA:

uses Windows, SysUtils, Forms, Classes, UnitB;
Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
5

You need to add the unit in which FormB is declared to your uses clause.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490