Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: Same Named Module and Procedure Causes Errors


View products that this article applies to.

This article was previously published under Q210098
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

↑ Back to the top


Symptoms

When you run a procedure from an object's events, you may receive the following error message:
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.
If you use the RunCode action in a macro to call a function, you may receive the following error message:
The expression you entered has a function name that Microsoft Access can't find.
If you try to run a procedure from the Immediate window, you may receive the following error message:
Compile Error:
Expected variable or procedure, not module.
NOTE: All the modules in the database or project will appear to compile successfully.

↑ Back to the top


Cause

A user-defined function or a subroutine have the same name as a module. These errors occur even if the procedure is not contained in the module with the same name.

↑ Back to the top


Resolution

Change the name of the module so that it is different from the name of any procedure that you have in the database or project.

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. Create a new Microsoft Access database, and then create a module.
  2. Type the following procedure:
    Function Test()
       MsgBox "Does this work correctly?"
    End Function
    					
  3. Save the module as Test.
  4. Type the following line in the Immediate window, and then press ENTER:
    Test
    					

↑ Back to the top


Keywords: KB210098, kbprb, kbprogramming, kberrmsg

↑ Back to the top

Article Info
Article ID : 210098
Revision : 2
Created on : 7/14/2004
Published on : 7/14/2004
Exists online : False
Views : 333