Best Place to write Code

Hai,

In form we have Init and data source init. which is the best place to write code.

What is the specific reason for it.

Thanks

What are you trying to achieve actually ??

Form level Init: as soon as the form is opened

Use the method to initialize a form. The init method is started immediately after thenew method and creates the run-time image of the form.

Typical uses of init include the following:

Modifying a form by using the FormBuild system class Initializing variables for specific controls on the form. You must call the super method if you override this method, and you should add your code before the super call.

In addition to creating the form, the call to the super method constructs the data source for the form by starting the init method on the data source. The form data source init method creates the query to fetch data from the database and sets up links if the form is linked to another form.

Form > Datasource level Init :

Creates a data source query based on the data source properties.

If there are more than one data source in the form and we need to do common functionality in both the data source then in the init method is the appropriate place to write the code.

If you want to do data source specific job then its better to write the code in form-> data source → init method.

example - >

suppose your form is getting called from some button and you want to filter certain records from the data sources used in the form.

then get the caller object in the form init method and do the functionality you want to in the form-> data source → init method.

Hope it may help you.

thanks

Hai Nihar and Vishal thanks for ur replies.