Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fix for Procedure Declaration Does Not Match Description of Event...?

Status
Not open for further replies.

jpstroud

Technical User
Jun 18, 2004
93
US
I came across a problem this morning where my DB code would display the error: "The expression On Load you entered as the event property setting produced the following error: Procedure declartion does not match description of event or procedure having the same name." as described in post thread702-1387305.

As I was able to find others with the same problem, but nothing which assisted me in fixing it, I was left to my own devices. However, I believe that I have found the solution and would like to share it with others. Please let me know if you find this helpful.

Now, to replicate this problem, I used the following code:
Code:
Private Sub Form_Load()
    If Nz(Me.OpenArgs, "") <> "" Then LoadForm
End Sub

Private Sub Form_Unload(Cancel As Integer)
    If Nz(Me.OpenArgs, "") = "NewRec" Then
        UnloadForm (org_Name.Value)
    End If
End Sub

Private Sub org_System_Enter(Cancel As Integer)
    If Nz(org_System.Value, "") = "" Then org_System.Value = org_Name.Value
End Sub

In the above code, I had made a seemingly simple change... I had modified the original org_System_Exit event to read org_System_Enter as I wanted the code to trigger when entering the control instead of leaving it.

Now, the error states that the On Load procedure is calling the error, which I believe is what has lead to so much confusion on this issue. Instead, I noticed that the above error was triggered due to the parameters following the Sub declaration, as the Enter event allows no parameters. I removed "Cancel as Integer" and all was well.

In summary, if you have the above error, check the rest of your code for unneccessarily declared parameters. This may just solve the issue for you.

Hope folks find it helpful!

J
 
Sorry, but you can't go creating your own events in Access unless you create your own class modules. Access is a bit picky about that and so you will not be able to use org_System_Enter.

The unfortunate thing is that you may have to delete that event from the code and import everything into a new mdb file. Once you go messing with events, Access can sometimes not recover from that within the same file.
 
I've never had a problem with modifying the events. As long as you know what syntax Access uses to name the events, it's fine. The only problem that comes up is knowing what parameters, if any, it asks for (which I had forgotten to remove in my case). If it turns out that things aren't working right, you can also remove the sub declaration, go into the properties event tab, choose [Event Procedure], then click the ... button. It will start a new declaration with the correct parameters. Not once have I had a database fail from doing this and I've been working with VBA and Access for 9 years.

That said, the post was to alert individuals (similar to the one in the linked thread) as to possible solutions. I would have posted it there, but the thread was locked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top