Microsoft Knowledge Base Email Alertz

(210098) - 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...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 210098 - Last Review: July 14, 2004 - Revision: 1.1

ACC2000: Same Named Module and Procedure Causes Errors

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).

On This Page

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.

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.

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.

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
    					

APPLIES TO
  • Microsoft Access 2000 Standard Edition
Keywords: 
kberrmsg kbprogramming kbprb KB210098
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Anonymous User Report As Irrelevant  
Written: 3/9/2008 11:10 AM
Thank you very much! That was completely awesome that you took the time to write this prob/solution up. It was the exact answer I needed. Thank you! Thank you!

Jim - jimheath NOSPAM-AT-NOSPAM austin.rr.com Report As Irrelevant  
Written: 11/9/2008 7:48 PM
Thank you for taking the time to put this solution out there. It was the exact soultion to my problem and ended hours of searching. I wish Microsoft was as helpful.

Jarod Chay Report As Irrelevant  
Written: 5/22/2009 2:14 PM
Another possible cause for this error is if your code is trying to use objects that don't exist in your references. For example, I had an Access form with the following method. Private Function DoStuff(exApp As Excel.Application) As Long My project doesn't have a reference to Excel, so I was getting the errors described in this article whenever any form event occurred (click a button, change a field value, etc.). To fix it, you can either add the missing reference or use late binding: Private Function DoStuff(exApp As Object) As Long Hope this comment helps someone some day!