I am using Delphi6
and have a data module with an ADO
DataSet
which is used by two forms, formA and FormB. Each form has a Datas
As you said you need seperate instances, then my solution would be to have a Datamodule variable in each form declaration:
TForm1 = class(TForm)
...
private
fDatamodule : TDatamodule1;
...
end;
procedure TForm1.FormCreate(Sender : TObject)
begin
fDatamodule := TDatamodule1.Create(self);
MyDatasource.Dataset := fDatamodule.MyDataset;
end;
(repeat for Form2 etc)
You have the same datamodule, instanciated twice and thus completely seperate from each other, but utilising the same business logic in each form.
Whilst on the subject, ensure your datamodule code does not make reference to either form. This is bad practice.