How Can I bring datasource active records to class and then to another form by using normal button click event.

Hi Friends,

I am having the scenario that to pass the active records from one form grid to another form VIA class. Can anyone help me to understand that how can I bring the active data source record(whole row) to one form to another via the class?

Can you tell us about your implementation? How/Why are using the class in between the forms?

Hi Kiranthi,

I asked this because I want to Process that class as intermediate between many forms. In that class, I am doing some calculation,

Ex : In my scenario, I am having two unbound real fields, based on the given values in that fields, I am going to process some calculation and then I am going to save that to the table. After that, I am going to show those calculated values via another form using table.

Can you tell us about your implementation? How/Why are using the class in between the forms?

So only I am using a class here.

There are several ways how you can design it; it all depends on your particular requirements (which are still unknown to us). For example, it’s not clear whether the second form will always be the same and if not, who’ll decide which form should be open.

Here is one possible implementation: the first form could call the calculation and then open the second form, passing the calculation result as a parameter.

Hi Martin,

Thanks for the reply.

whether the second form will always be the same and if not, who’ll decide which form should be open?

Yes the second form will always be the same.

Here is one possible implementation: the first form could call the calculation and then open the second form, passing the calculation result as a parameter.

shall You give an example? How can I call the second form from class with the calculated values as parameter?

If it’s always the same, then I would prefer having a menu item in form A pointing to the class and opening form B from code in the class. This would allow you simply drag & drop the menu item to any form and you wouldn’t have to worry about form B.
Note that using a menu item is much better than manually adding buttons and clicked() method to all such forms. It’s less work, it’ll make sure that labels and help texts are used consistently, you can configure security on menu item, fixes can be done at a single place and so on…
The problem is how to get values of your unbound controls to your class. One way is considering if they really must be unbound - if you can bind them to a data source (even one that never gets saved to database), you can simply set the DataSouce property of the menu item and the record will be automatically sent to your class. This may be the best solution.
If it’s not suitable, you can either push values to the class and let the class ask the form for these values.

Thanks, Martin.