How about making the DataModule a property of the main form, instantiated in the form's OnCreate? I did this once for an MDI app using ADO where all instances of the datamodule shared a single Connection instance.
Bob > > From: "Allan, Samuel" <[EMAIL PROTECTED]> > Date: 2003/12/08 Mon PM 01:18:17 GMT+13:00 > To: <[EMAIL PROTECTED]> > Subject: [DUG] Form / DataModule Creation > > I have a form / datamodule pair that are created / destroyed together, > and there can be more than one instance of this pair. Visual components > on the form are linked at design time to datasources / datasets on the > datamodule. > > The first pair (named SamForm and SamDataModule) create fine. The second > pair (SamForm_1 and SamDataModule_1) do not. The visual components on > SamForm_1 are all linked to SamDataModule and not SamDataModule_1, which > is what I want. > > I worked around this by re-setting all the links for the visual > components by hand at creation. However, this is not a good solution. > Someone else maintaining my code must know what I am doing and why. If I > add a new DBEdit then I have to remember to add the linking code to the > creation as well, or the DBEdit will look at the wrong data. Simply > moving the DataSource to the form lessens the impact, but does not > eliminate the problem, and some people in my work disagree with doing > this. Also, some visual components, like InfoPower link directly to the > dataset anyway. This must be something that others have experienced. > > Is there a better solution? > > _______________________________________________ > Delphi mailing list > [EMAIL PROTECTED] > http://ns3.123.co.nz/mailman/listinfo/delphi > _______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
