Re : passing values between two forms

This is a test program showing (twice) the method i use. As Mats Anderson said in another
posting here, you use properties. Try it, it works. (no dfms though)
================================================================
unit Prop1;
{this unit is the main unit for the project, and uses prop2.

Quote
}

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, prop2, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    procedure setdata(newdata : testrec);
    function getdata : testrec;
    procedure ButtonClick(Sender: TObject; blankit : boolean);

  public
    { Public declarations }
    property formdata : testrec read getdata write setdata;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
procedure tform1.setdata(newdata : testrec);
begin
    with newdata do begin
      if b1 then label2.caption := 'True'
            else label2.caption := 'False';
      Label1.caption := st;
    end;
end;
function tform1.getdata : testrec;
begin
    with result do begin
      b1 := (label2.caption = 'True');
      st := Label1.caption;
    end;
end;
procedure TForm1.ButtonClick(Sender: TObject; blankit : boolean);
var
  tb : boolean;
begin
      if blankit then BtnRightDlg.blank
                 else BtnRightDlg.formdata := self.formdata;
      tb := BtnRightDlg.execute;
      if tb then begin
         self.formdata := BtnRightDlg.formdata;
         label3.caption := 'Pressed OK';
      end
      else label3.caption := 'Pressed Cancel';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
     ButtonClick(Self, true);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
     ButtonClick(Self, false);
end;

end.

================================================================
unit Prop2;
{this unit contains a pop up form ,and also the type definiton
(testrec) for the properties used by the 2 form objects}

interface
uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls;

type

{NB type definition for property types}

  testrec = record
     st : string;
     b1 : boolean;
  end;

  TBtnRightDlg = class(TForm)
    OKBtn: TBitBtn;
    CancelBtn: TBitBtn;
    label1: TLabel;
    CheckBox1: TCheckBox;
    Edit1: TEdit;
  private
    { Private declarations }
    procedure setdata(newdata : testrec);
    function getdata : testrec;
  public
    { Public declarations }
    property formdata : testrec read getdata write setdata;
    function execute : boolean;
    procedure blank;

  end;

var
  BtnRightDlg: TBtnRightDlg;

implementation

{$R *.DFM}

function tBtnRightDlg.execute : boolean;
begin
    if not showing then showmodal;
    result := (modalresult = mrOK);
end;

procedure tBtnRightDlg.blank;
var
  tr : testrec;
begin
    fillchar(tr,sizeof(testrec),0);
    formdata := tr;
end;

procedure tBtnRightDlg.setdata(newdata : testrec);
begin
    with newdata do begin
      CheckBox1.checked := b1;
      Edit1.text := st;
    end;
end;

function tBtnRightDlg.getdata : testrec;
begin
    with result do begin
      b1 := CheckBox1.checked;
      st := Edit1.text;
    end;
end;

end.