You receive a "Compile error" error message when you run a function or a procedure in Access 2002 (312851)



The information in this article applies to:

  • Microsoft Access 2002

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

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

For a Microsoft Access 2000 version of this article, see 210098.

SYMPTOMS

When you run a procedure or a function, you may receive one of the following error messages:
Compile error:

Expected variable or procedure, not module.

-Or-

Microsoft Access can't find the name 'ProcedureName' you entered in the expression.

-Or-

The expression you entered has a function name that Microsoft Access can't find.
All the modules in the database or the project compile successfully.

CAUSE

These errors can occur if a user-defined function or a subroutine has the same name as a module.

RESOLUTION

To resolve these errors, change the name of the module so that the name is different from the name of any procedure or function that you have in the database or project.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new 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
    					

Modification Type:MinorLast Reviewed:8/13/2004
Keywords:kberrmsg kbprb KB312851