views:

61

answers:

1

I am sorry if the title is wrong, but I think that is what I mean to ask.

So I have a subform created that I would like to use, sort of like a control panel, that allows user to select a range of different forms. So the same subform ends up in a lot of different parent forms. I would like to use simple

docmd.close acform

but i am looking for a way to reference the parent form like "active form" or something like that so I can close whatever form is open before opening the intended form. that way i can use the same sub form (control panel) in a lot of forms and it works globally??

thanks justin

+2  A: 

From within the subform you can get the name of its parent form with:

Me.Parent.Name
HansUp
thanks! once again, just what i needed!
Justin
You're welcome. Beware, if you ever open the subform's form on its own (not as a subform of a parent form), Me.Parent will give you an Invalid Reference error. You can trap that error if needed with code like http://stackoverflow.com/questions/3028760/possible-to-set-filter-on-subform-from-parent-form-before-subform-data-loads/3029381#3029381
HansUp
Also I'm unsure whether you can have a subform close its parent, then open a different form. You might have better luck opening the new form, then closing the previous parent.
HansUp
seems to be working just fine. I am simply using this ONLY as a control panel (navigation menu) for all available forms within a certain context. There is no need to have the form open on its own. Yes it seems to work closing the parent form, then opening the new one. I already changed and tested that method, and it is working fine so??? thanks Hans!!
Justin
If you use Me.Parent, it returns a form object, and can be used like any form reference. Doesn't help your problem, but I thought it was useful for that to be explicitly mentioned.
David-W-Fenton