INF: "There Is No Current Code Context Object" Error Message

    Article ID: Q147153
    Creation Date: 20-FEB-1996
    Revision Date: 20-SEP-1996

    The information in this article applies to:

    • Microsoft Access version 7.0

    SYMPTOMS

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

    The CodeContextObject property can only be used to refer to the current Form or Report object. Functions using the CodeContextObject property can only be called from the Form or Report object. If the function is called from the Debug window, you may receive the following error message:

       There is no current code context object.
    
    
    STATUS

    This behavior is by design.

    MORE INFORMATION

    Steps to Reproduce Behavior

    1. Create a new module and type the following code:

            Function ErrorMessage()
               Dim objCurrent As Object
               Set objCurrent=CodeContextObject
               ErrorMessage=objCurrent.Name
               MsgBox ErrorMessage
            End Function
      
    2. Create a new form and save it as TestContext.
    3. Add a command button to the TestContext form.
    4. Set the command button's OnClick property as follows:

           =ErrorMessage()
      
    5. View the TestContext form in Form view.
    6. Click the command button. Note that you receive a message with the name of the form.
    7. Press CTRL+G to display the Debug window.
    8. In the Debug window, type the following line, and then press ENTER:

            ?Errormessage()
      

      Note that you receive the following error message:

              There is no current context object.
      

    REFERENCES

    For more information about CodeContextObject property, search for "CodeContextObject" using the Microsoft Access for Windows 95 Help Index.


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.
©1997 Microsoft Corporation. All rights reserved. Legal Notices.

Additional reference words: 7.00 7955
KBCategory: kbprg kberrmsg
KBSubcategory: PgmObj