ACC: GoToRecord Macro Does Not Work on Subform

Last reviewed: May 7, 1997
Article ID: Q92685
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

If you create a GoToRecord macro that points to a subform and run that macro from the main form, you may receive the following error message:

   Object '<Subform Name>' isn't open

RESOLUTION

Use a GoToControl macro action to specify the subform control name, and then use the GoToRecord action to move to the next record within the subform. Leave the ObjectType and ObjectName arguments of the GoToRecord action blank and set the Record argument to Next.

STATUS

This behavior is by design.

MORE INFORMATION

The "GoToControl Action" Help topic contains a tip which reads as follows:

   Tip   You can use the GoToControl action to move to a subform, which is
   a type of control. You can then use the GoToRecord action to move to a
   particular record in the subform.

This is correct, but it is necessary to leave the ObjectType and ObjectName arguments for the GoToRecord action blank for this to work successfully.

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb (or NWIND.MDB for version 2.0 and earlier), and then create the following new macro:

          Macro Name     Condition     Action
          ---------------------------------------
          Macro1                       GoToRecord
    
          Macro1 Actions
          -----------------------------------------
          GoToRecord
             Object Type: Form
             Object Name: Quarterly Orders Subform
                  Record: Next
                  Offset: <blank>
    
    

  2. Open the Quarterly Orders form.

  3. Do one of the following, depending on your version of Microsoft Access:

    In Microsoft Access 97:

         On the Tools Menu, click Run Macro, select Macro1, and click OK.
    

    In Microsoft Access 7.0:

         On the Tools Menu, click Macro, select Macro1, and click OK.
    

    In Microsoft Access 1.x and 2.0:

         On the File menu, click Run Macro, select Macro1, and click OK.
    

    Note that you receive the following error message:

          Object 'Quarterly Orders Subform' isn't open
    

  4. Change Macro1 as follows:

          Macro Name     Condition     Action
         -----------------------------------------
          Macro1                       GoToControl
                                       GoToRecord
    
          Macro1 Actions
          -----------------------------------------
          GoToControl
             Control Name: Quarterly Orders Subform
          GoToRecord
              Object Type: <blank>
              Object Name: <blank>
                   Record: Next
                   Offset: <blank>
    
    
Run the macro in the same way as in step 2. Note that the macro moves the focus to the next record in the Quarterly Orders Subform.


Keywords : FmsEvnt kberrmsg kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


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: May 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.