Shamil Salakhetdinov
shamil at users.mns.ru
Sat Mar 18 10:46:30 CST 2006
Steve, Here is the code to call from subform: Dim ectl As Access.Control Dim fsub As Access.SubForm For Each ectl In Me.Parent.Controls If ectl.ControlType = acSubform Then Set fsub = ectl If Len(fsub.SourceObject) > 0 Then If Not fsub.Form Is Nothing Then If fsub.Form Is Me.Form Then MsgBox "My subform control name is " & fsub.Name, _ vbInformation + vbOKOnly End If End If End If End If Next ectl Be careful with calling this code from subform's Open or Load event, especially in the case when on main form there are several subform controls using the same form.... HTH, Shamil ----- Original Message ----- From: "Steve Erbach" <erbachs at gmail.com> To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> Sent: Saturday, March 18, 2006 4:52 PM Subject: [AccessD] Acquiring subform's subform object name > Dear Group, > > I have a form, frmMainMenu, that contains a Tab Control. The 8 tabs > in the Tab Control are generically named Tab1, Tab2, etc. > > Each of the Tabs has one Subform Control "embedded" in it; each > Subform is also generically named: Subform1, Subform2, etc. The > reason for this is that frmMainMenu is set up with another Subform > Control "outside" the Tab Control. This subform acts like the > vertical menu in an Access database window. Once a menu item is > clicked, then all the tabs change, sometimes fewer tabs visible, > sometimes more, depending on which vertical menu item is selected. > > Anyway my problem is this: > > Say that Tab3's subform control, Subform3, has the form frmCustomers > as the subform's Source Object. From the code within frmCustomers I > would like to be able to determine the name of it's subform control > "container". > > Me.Parent.Name gives me the name of the "master" form, frmMainMenu. > I've tried all sorts of things short of enumerating the collection of > controls to simply find the name of the subform control that > "contains" frmCustomers. > > Could you give me an idea? > > Regards, > > Steve Erbach > Scientific Marketing > Neenah, WI > http://TheTownCrank/blogspot.com > Security Page: www.swerbach.com/security > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com