Microsoft Knowledge Base Email Alertz

When you open a form in browse mode, and then run any code on that form, you may receive the following error message

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: 286595 - Last Review: September 26, 2003 - Revision: 3.0

ACC2002: Error When You Run RecordExit Function or Sub Procedure

This article was previously published under Q286595
Advanced: Requires expert coding, interoperability, and multiuser skills.

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

SYMPTOMS

When you open a form in browse mode, and then run any code on that form, you may receive the following error message
The expression EventName you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name.

* The expression may not result in the name of a macro, the name of a user-defined function, or an [Event Procedure].

* There may have been an error evaluating the function, event, or macro.
where EventName is the event from which you attempted to run the code.

When you compile the project, you receive the following error message:
Compile Error:

Procedure declaration does not match description of event or procedure having the same name.
The following line appears highlighted as the cause of the compile error:
Sub Form_RecordExit()
				

CAUSE

This issue occurs when a Sub procedure or function is named Form_RecordExit(). This name overlaps a hidden Access form event named RecordExit, which requires a specific syntax.

Although you can create an event procedure to run against this event without harming your form behavior, you must provide the correct parameter syntax when you call the procedure. Without the correct syntax, the project does not compile, and any code that you run on the form returns the error message described in the "Symptoms" section.

RESOLUTION

To resolve this issue, use either of the following methods:
  • Rename the Sub procedure or function, and change any code that references it. This is the preferred method.

    -or-

  • If you must use the name Form_RecordExit(), change the declaration syntax of the Sub procedure or function, and change the syntax of any calls to the procedure to provide the correct parameters.

    To change the declaration, use the following syntax:
    Sub Form_RecordExit(Cancel as Integer)
         'User Code Here
    End Sub
    						
    To properly call the code, use the following syntax, which includes a parameter:
    Sub MySub()
        Call Form_RecordExit(0)
        'Other User Code Here
    End Sub
    						

MORE INFORMATION

In Microsoft Access 2002, the object model for forms contains a hidden event named RecordExit. Because the event is hidden, it does not appear in the Property list for the form object in the Visual Basic Environment (VBE). However, if you write a Sub procedure named Form_RecordExit(), the procedure does not work unless it uses a specific syntax.

This hidden event did not exist in Microsoft Access 2000 or earlier.

If you write a project in Access 2000 and then open it in Access 2002, Access silently uncompiles the project. You do not receive any notification until you open the form and attempt to run Microsoft Visual Basic for Applications (VBA) code in it, or until you try to recompile the project.

REFERENCES

For additional information about how to implement the RecordExit event, click the article number below to view the article in the Microsoft Knowledge Base:
304139  (http://kbalertz.com/Feedback.aspx?kbNumber=304139/EN-US/ ) How to Programmatically Implement a RecordExit Event

APPLIES TO
  • Microsoft Access 2002 Standard Edition
Keywords: 
kbprb KB286595
       

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