ACC: Same Named Module & Function Cause Error After Conversion

Last reviewed: August 28, 1997
Article ID: Q148529
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SYMPTOMS

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

If a database that has been converted from Microsoft Access 2.0 to Microsoft Access 7.0 or Microsoft Access 97 contains a user-defined procedure and a module with identical names, you may receive the following error message when the procedure is run from an object's events.

In Microsoft Access 97:

   The expression [event name] you entered as the event property setting
   produced the following error: The expression you entered has a function
   name that Microsoft Access can't find.

In Microsoft Access 7.0:

   The expression [event name] you entered as the event property setting
   produced an error. There was an error compiling this function.

If you use the RunCode action in a macro to call the function, then you may receive the following error message:

In Microsoft Access 97:

   The expression you entered has a function name that Microsoft Access
   can't find.

In Microsoft Access 7.0:

   There was an error compiling this function. The Visual Basic module
   has a syntax error. Solution: Check the code and then recompile it.

If you try to run the procedure from the Debug window, then you may receive the following error message:

   Expected variable or procedure, not module.

These errors occur even if the procedure is not contained in the module with the same name.

NOTE: All the modules in the converted database will appear to compile successfully.

NOTE: This behavior is exposed only when the function is initially run because Microsoft Access 7.0 and 97 do not load a module until a function or subroutine within the module is called.

CAUSE

This behavior is likely to occur after you convert a database from Microsoft Access version 2.0, which does allow a user-defined function and module to have the same name.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Microsoft Access 2.0 database, create a module, and type the following line in the Declarations section:

          Option Explicit
    

  2. Type the following procedure:

          Function Test()
    
             MsgBox "I am working correctly"
          End Function
    
    

  3. Save the module as Test.

  4. Create the following blank form and save it as Test1:

          command button:
    
             Name: Button0
             Caption: My Button
             OnClick: =Test()
    
    

  5. Switch the Test1 form to Form view. Note that the button behaves as expected by displaying a message box when you click the button.

  6. Quit Microsoft Access version 2.0.

  7. Start Microsoft Access 97.

  8. On the File menu, click Open, and select the database you created in step 1.

  9. When prompted to Open or Convert the database, select Convert.

  10. Open the Test1 form in Form view.

  11. Click My Button. Note that you receive the error message mentioned

        in the "Symptoms" section.
    


Additional query words: conversion name
Keywords : CnvProb kberrmsg kbprg MdlGnrl
Version : 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbprb
Solution 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: August 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.