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