Hello Everyone,

I have what I hope will be a simple VB question:

I am building an app with multiple forms. It has a MainForm, which is the main interface, and several sub-forms that are started using buttons on the MainForm.

The MainForm Load method has some code that runs each time the form starts. This code populates various fields in the MainForm and it works fine. When I click a button a sub-form loads. I update some data there and then close or hide this form.

My problem is this: When I close or hide the sub-form and show the MainForm again, is it possible to have the MainForm Load method 're-run', or execute again? I presume I might be able to add something to the sub-form "Back" button event that runs when I hide or close the sub-form. I've tried a few variations of "frmMainForm.this" and "frmMainForm.that" with no luck.

I want to do this because the MainForm Load code will pick up the changes I made in the sub-form and display the updated data in the text fields of the MainForm.

Any advice is greatly appreciated. Many Thanks!

Tyster

The best you can do here, is to write a Sub, call it from the form.Load AND when the subform is closed.

In order to know when the subform closes, open the subform with subform.ShowDialog, right after that sentence, call the same sub you call when form.Load occurs.

Thanks, dxider.... I wrote a new function that allowed me to pass the data I needed to MainForm and it works fine. I appreciate your input very much!

Many Thanks!!!

Tyster

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.