Microsoft KB Archive/100025

= ACC: How to Use the Parent Property of a Subform =

Article ID: 100025

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q100025



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



SUMMARY
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:

 Open the sample database Northwind.mdb (or NWIND.MDB in Microsoft Access 2.0 or earlier)  Create and save the following macro:

     Macro: Get Parent Name ---     Action: MsgBox Message: =Forms!Orders![Orders Subform].Form.Parent.Name Title: Parent Form Name   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  Save and close Orders Subform. Open the Orders form. Double-click the ProductID field in the subform. Note that the parent form name, Orders, is displayed.</li> Close the Orders form. Open the Orders Subform form in Design view and remove the macro you added in step 2.</li></ol>

Additional query words: main mainform sub

Keywords: kbhowto kbusage KB100025

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.