Your variables and procedures should be in the memory of the form. Consider it like, what if you create 2 of these custom forms? Instead of procedure buildBForm; , while it works, it would be better practise to create the components in the form constructor.
TFormB = class(TForm)
Button1, Button2, Button3, Button4: TButton;
procedure OkayButtonClick(Sender: TObject);
public
constructor Create;
end;
implementation
constructor TFormB.Create;
begin
Left:=442;
Height:=338;
Top:=40;
Width:=676;
Caption:='Incorporate into Database';
Font.Name:='MS Sans Serif';
Button3:=TButton.Create(self);
with Button3 do
begin
Parent:=self; // SELF here
Left:=320;
Height:=25;
Top:=269;
Width:=75;
Caption:='Okay';
Default:=True;
OnClick:=@OkayButtonClick;
TabOrder:=0;
end;
end;
procedure TFormB.OkayButtonClick(Sender: TObject);
begin
//...
end;