ACC: How to Use the Parent Property of a Subform

Last reviewed: April 2, 1997
Article ID: Q100025
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Novice: Requires knowledge of the user interface on single-user computers.

This article describes how to use a subform's Parent property to return the name of its parent form.

MORE INFORMATION

The following is the correct syntax for the Parent property in macro actions called from a subform:

   Forms![Main Form Name]![Subform ControlName].Form.Parent.Name

   -or-

   Form.Parent.Name

   -or-

   Parent.Name

The following example demonstrates how to use the Parent property in a macro:

  1. Open the sample database Northwind.mdb (or NWIND.MDB in Microsoft Access 2.0 or earlier)

  2. Create and save the following macro:

          Macro: Get Parent Name
          ---------------------------------------------------------------
          Action: MsgBox
    
             Message: =Forms!Orders![Orders Subform].Form.Parent.Name
             Title: Parent Form Name
    
    

  3. Open the Orders Subform form in Design view. Add the Get Parent Name macro to the OnDoubleClick event of the ProductID field (or Product ID in versions 1.x and 2.0):

          Object: Text Box
          --------------------------------------------------------------
          ControlName: ProductID (or Product ID in versions 1.x and 2.0)
    
             OnDblClick: Get Parent Name
    
    

  4. Save and close Orders Subform.

  5. Open the Orders form. Double-click the ProductID field in the subform. Note that the parent form name, Orders, is displayed.

  6. Close the Orders form. Open the Orders Subform form in Design view and remove the macro you added in step 2.


Additional query words: main mainform sub
Keywords : FmsSubf kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.