Board index » delphi » Datamodule and MDI form

Datamodule and MDI form

I am creating an instance of a datamodule in my MDI child forms.
How can I access that datamodule from forms created within the MDI child.

Uses ......CALDM1;
.....
  public
    { Public declarations }
    DMCal: TCal_Dm;
.....

Implementation

procedure TCTRForm.FormCreate(Sender: TObject);
.....
  DMCal:=TCal_Dm.Create(Self);
end;

I can not see the instance of  DMCal in a form created from within this MDI
Form below, but need to access functions and data in the datamodule;
procedure TCTRForm.PrintBtnClick(Sender: TObject);
begin
    ReportDlgGS := TReportDlgGS.Create(self);
    with ReportDlgGS do
    begin
      try
         ReportDlgGS.ShowModal;
      finally
         ReportDlgGS.Free;
      end; { try }
......

Helmut

 

Re:Datamodule and MDI form


I think You have to pass the calling form to the ReportDlgGS, or you may use
the Owner property of ReportDlgGS which should be the MDI form which created
that ReportDlgGS.

in example
  with Owner.DMCal do
    {what ever you want to do with data}
  end;

Gert

Quote
Helmut Leitner <hleit...@ctr.com.au> wrote in message

news:7tgndo$ab33@forums.borland.com...
Quote
> I am creating an instance of a datamodule in my MDI child forms.
> How can I access that datamodule from forms created within the MDI child.

> Uses ......CALDM1;
> .....
>   public
>     { Public declarations }
>     DMCal: TCal_Dm;
> .....

> Implementation

> procedure TCTRForm.FormCreate(Sender: TObject);
> .....
>   DMCal:=TCal_Dm.Create(Self);
> end;

> I can not see the instance of  DMCal in a form created from within this
MDI
> Form below, but need to access functions and data in the datamodule;
> procedure TCTRForm.PrintBtnClick(Sender: TObject);
> begin
>     ReportDlgGS := TReportDlgGS.Create(self);
>     with ReportDlgGS do
>     begin
>       try
>          ReportDlgGS.ShowModal;
>       finally
>          ReportDlgGS.Free;
>       end; { try }
> ......

> Helmut

Re:Datamodule and MDI form


Sorry, it should be something like

  with (Owner as TCTRForm).DMCal do

Gert

Quote
Gert Kello <Gert.Ke...@mail.ee> wrote in message

news:7thfgi$eo86@forums.borland.com...
Quote
> I think You have to pass the calling form to the ReportDlgGS, or you may
use
> the Owner property of ReportDlgGS which should be the MDI form which
created
> that ReportDlgGS.

> in example
>   with Owner.DMCal do
>     {what ever you want to do with data}
>   end;

> Gert

Re:Datamodule and MDI form


Thanks will try it right now

Helmut

Quote
Gert Kello <Gert.Ke...@mail.ee> wrote in message

news:7thfl3$em39@forums.borland.com...
Quote
> Sorry, it should be something like

>   with (Owner as TCTRForm).DMCal do

> Gert

> Gert Kello <Gert.Ke...@mail.ee> wrote in message
> news:7thfgi$eo86@forums.borland.com...
> > I think You have to pass the calling form to the ReportDlgGS, or you may
> use
> > the Owner property of ReportDlgGS which should be the MDI form which
> created
> > that ReportDlgGS.

> > in example
> >   with Owner.DMCal do
> >     {what ever you want to do with data}
> >   end;

> > Gert

Other Threads