Master save on a mdi parent

I have a mdi parent (frmParent) and a child (frmChild).  On the child is a tabcontrol with 2 tabs.  On each tab are datasets: tab1 has textboxes bound to ds1 and ds2; tab2 has textboxes bound to ds3 and ds4.

I have no problem with individual save buttons on each tab page to check for changes and then update the database.  My problem is using the Save on frmParent.  I want a "master" save button that will check for all the respective tab pages.

I know how to identify the active child form, e.g., Dim f as Form = me.ActiveMdiChild.  How do I identify programmically what datasets are associated with what tab page?  Somehow I need to cycle through each tab page, check whatever datasets are on it, and update as needed.

Can you help?
vlvawterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brian CroweDatabase AdministratorCommented:
dont' try and do the saving within the parent.  Just create a method in the child form that saves all the data on that form.

class frmChild
...
public sub SaveAll()
   'save changes
end sub
0
vlvawterAuthor Commented:
Are you saying not to save inside the parent because it is too complicated or because it cannot be done?

Also, if I create a control for frmChild that activates "Save All," is there a way to raise that event from frmParent?
0
Brian CroweDatabase AdministratorCommented:
It's bad design.  One of the principles of object-oriented programming and design is encapsulation.  Members (variables) within a class should not be directly manipulated or accessed from outside the class.

You don't need to add a control or raise event (although adding a delegate to take care of this is an option).  Just add the method to your childform.

if typeof(me.activemdichild) is frmchild then
   ctype(me.activemdichild, frmchild).saveall
end if

You could also use reflection to determine if a given child has the "SaveAll" method.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vlvawterAuthor Commented:
I simply added a toolstrip on frmChild with a save icon.  The code behind that is a SaveAll.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.