ACC2: DeleteObject Action Causes "Illegal Function Call" Msg

Last reviewed: June 8, 1997
Article ID: Q122712
The information in this article applies to:
  • Microsoft Access version 2.0

SYMPTOMS

Advanced: Requires expert coding, interoperability, and multiuser skills.

When you use the DeleteObject action in Access Basic code to delete a module, you may receive the error message "Illegal function call." When you use this action in a macro, the module is deleted correctly.

CAUSE

When Microsoft Access runs an Access Basic function, it loads all modules into memory. If you add or delete a function, Microsoft Access must recompile the code, but it cannot do so while the code is running.

RESOLUTION

In Microsoft Access version 7.0, the following function correctly deletes a module:

   Function DelModule()
      DoCmd.DeleteObject A_MODULE, "Delete Test"
   End Function

Note that DeleteObject will enable you to delete any module, including the module which contains the DelModule() function.

STATUS

This behavior no longer occurs in Microsoft Access version 7.0.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new module.

  2. Enter the following function in the module:

          Function DelModule()
    
             DoCmd DeleteObject A_MODULE, "Delete Test"
          End Function
    
    

  3. Save the module as Test.

  4. Create another new module.

  5. Enter the following function in the module:

          Function TestFunction()
    
              MsgBox "Test Function"
          End Function
    
    

  6. Save the module as Delete Test.

  7. From the View menu, choose Immediate window.

  8. In the Immediate window, type the following line, and then press ENTER:

          ? DelModule()
    

    Note that you receive the error message mentioned earlier in this article.


Keywords : kberrmsg kbprg PgmObj
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : kbfix


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