Board index » delphi » Sharing Datsource from form1 to form2?

Sharing Datsource from form1 to form2?

I was wondering if you could help me with this problem I am having
sharing a Datasource from Form1 in form2:

procedure form2.FormActivate(Sender: TObject);
var I: Integer;
begin
 for I:= 0 to ComponentCount-1 do
 if Components[I] is TDBedit then
 begin
  TDBEdit(Components[I]).DataSource:= Form1.DataSource1;
  TDBEdit(Components[I]).DataField:= Form1.Table1.Fields[I].FieldName;
 end;
end;

My problem is that there are other controls on the form other than
TDBedits.  Like buttons and panels, and other TDBControls such as
TDBComboBox.

Would you know how to accomplish this sharing of the Datasource/Dataset
I just can't seem to figure this out.  

Shane Holmes

 

Re:Sharing Datsource from form1 to form2?


Did you try using the Data Module ?? (if you have Delphi 2, that is)

keith

Quote
holme...@netsrq.com (Shane Holmes) wrote:
>I was wondering if you could help me with this problem I am having
>sharing a Datasource from Form1 in form2:
>procedure form2.FormActivate(Sender: TObject);
>var I: Integer;
>begin
> for I:= 0 to ComponentCount-1 do
> if Components[I] is TDBedit then
> begin
>  TDBEdit(Components[I]).DataSource:= Form1.DataSource1;
>  TDBEdit(Components[I]).DataField:= Form1.Table1.Fields[I].FieldName;
> end;
>end;
>My problem is that there are other controls on the form other than
>TDBedits.  Like buttons and panels, and other TDBControls such as
>TDBComboBox.
>Would you know how to accomplish this sharing of the Datasource/Dataset
>I just can't seem to figure this out.  
>Shane Holmes

Re:Sharing Datsource from form1 to form2?


Someone has produced a Datasource component which can be shared by forms
on the Delphi Super Page - Shareware. I haven't tested it, but you could
try it.

Other Threads