Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Linking event from Database form to Main form
Fri, Nov 25 2016 3:02 AMPermanent Link

Richard Mace

Hi,

I have created a database, in the database manager, and dragged it up to the units section of the project manager. All is well, and everything gets created automatically, including the form being auto created at start up.

The issue that I am having is that I want to link an AfterLoad event, from a dataset on the Database form, through to my main form. Everything seems to go fine, until I execute this code in the main form OnShow event.

DBMain.OnDatasetLoad := TrapOnDatasetJobsLoad;

The issue is that the DBMain (my Database form) hasn't been auto created yet, and I know this because if I place a button on the form and then click that (a few seconds after my main form has loaded) it works fine.

I have tried to remove the form from being auto created, and manually create it myself, but then I get issues with the dataset objects on the Database form.

Any ideas what I'm not doing correctly?

Thanks in advance

Richard
Fri, Nov 25 2016 4:24 AMPermanent Link

Matthew Jones

Richard wrote:

> The issue is that the DBMain (my Database form) hasn't been auto created yet, and I know this because if I place a button on the form and then click that (a few seconds after my main form has loaded) it works fine.

I have found that it is often easiest in these cases to create a procedure which does the linking up and setup, and then call that in the Form OnShow using async, or a timer on a fast time. Async seems best though.

The key is that the UI and everything is all set up, and then the async happens, so it should all be good by then.

And if that doesn't fix it, then something else is wrong with your code. 8-)

--

Matthew Jones
Mon, Nov 28 2016 1:32 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< I have created a database, in the database manager, and dragged it up to the units section of the project manager. All is well, and everything gets created automatically, including the form being auto created at start up.

The issue that I am having is that I want to link an AfterLoad event, from a dataset on the Database form, through to my main form. Everything seems to go fine, until I execute this code in the main form OnShow event.

DBMain.OnDatasetLoad := TrapOnDatasetJobsLoad;

The issue is that the DBMain (my Database form) hasn't been auto created yet, and I know this because if I place a button on the form and then click that (a few seconds after my main form has loaded) it works fine. >>

Just make sure that the TDatabase instance is created *before* the main form.  You can do this in the Project/Options/Forms and Databases.  Just drag and drop the TDatabase instance so that it's before the main form.  In EWB, unlike Delphi, you can have something designated as the main form even if it isn't the first form/database instance to be created.

Tim Young
Elevate Software
www.elevatesoft.com
Image