title: Cross-form variable with Multiple forms
body: <p>I'm a Highschool student working with Delphi 2010 and currently working on a projects. I'm having some trouble using a variable assigned a value on one form, on another whilst using "ShowModal" to view the second.  </p>
  
  <p>Here's what I have on the First Form (only 1 Click procedure is shown as it repeats): </p>
  
  <pre><code>  unit frmSkill_u;
  
      interface
  
      uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
        Dialogs, StdCtrls, ExtCtrls, Buttons, jpeg, dmMusiektukke_u, DBGrids, PAT, frmMusiek_u  ;
  
      type
       TfrmSkill = class(TForm)
      Panel1: TPanel;
      pnlBegin: TPanel;
      bitbtnMain: TBitBtn;
      pnlEasy: TPanel;
      pnlInter: TPanel;
      pnlAdv: TPanel;
      Image1: TImage;
      Label1: TLabel;
      procedure bitbtnMainClick(Sender: TObject);
      procedure pnlBeginClick(Sender: TObject);
      procedure pnlEasyClick(Sender: TObject);
      procedure pnlInterClick(Sender: TObject);
      procedure pnlAdvClick(Sender: TObject);
      private
  
      { Private declarations }
    public
    iLevel : integer ;
      { Public declarations }
    end;
  
  var
  
    frmSkill: TfrmSkill;
  
  
  implementation
  
  
  
  {$R *.dfm}
  
  
  procedure TfrmSkill.bitbtnMainClick(Sender: TObject);
  begin
  frmInstru.Visible := True ;
  end;
  
  procedure TfrmSkill.pnlBeginClick(Sender: TObject);
  begin
  
     iLevel := 0 ;
   frmMusic.ShowModal ;
  
  end;
  </code></pre>
  
  <p>A button will be clicked to assign which level the person can play an instrument on (Beginner level = 0) and then the second form will show using the iLevel variable in a Case statement to filter a Database according to which level the person selected. </p>
  
  <p>The second form : </p>
  
  <pre><code> unit frmMusiek_u;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, dmMusiektukke_u, Grids, DBGrids, StdCtrls, Buttons, frmSkill_u;
  
  type
    TfrmMusic = class(TForm)
      dbgMusiekstukke: TDBGrid;
      BitBtn1: TBitBtn;
      procedure FormCreate(Sender: TObject);
    private
      { Private declarations }
    public
  
      { Public declarations }
    end;
  
  var
  
    frmMusic: TfrmMusic;
  
  implementation
  
  
  
  {$R *.dfm}
  
  procedure TfrmMusic.FormCreate(Sender: TObject);
  begin
    case frmSkill.iLevel of
      0:
        begin
          with dmMusiekstukke do
          begin
             tblMusiekstukke.Filter := 'Difficulty = ''Beginner''' ;
            tblMusiekstukke.Filtered := True;
           end;
        end;
    end;
  
  end;
  end.
  </code></pre>
  
  <p>However, the post's method I've seen on using variable across different forms (<a href="https://stackoverflow.com/questions/8551768/passing-the-variable-to-another-form">Passing the variable to another Form</a>) cannot work here until I figure out how to get rid of the <em>[DCC Fatal Error] frmSkill_u.pas(7): F2047 Circular unit reference to 'frmSkill_u'</em> error when adding "frmSkill_u" to the Uses of the second form.</p>
  
  <p>How can I still use such a variable and show the second form contemporarily? </p>
  
  <p>Thank you very much!</p>