Microsoft KB Archive/190943

= PRB: ACC97: Run Method Can't Find Procedure Although It Exists =

Article ID: 190943

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Visual Basic for Applications 5.0
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q190943



SYMPTOMS
You attempt to use the Run method in Microsoft Access 97 (or from automation) to run a custom procedure in a database. Although the correct database is open and the procedure exists, you get the following error using the Run method:

  Run-time error '2517': Microsoft Access can't find the procedure.



CAUSE
This problem occurs if the name of the procedure matches the name of a module in the database. Also, each form and report object in the database may be given a hidden module automatically. These module names are Form_ if the module is for a form, or Report_ if the module is for a report. Therefore, if the name of the procedure you are unable to run begins with Form_ or Report_, the problem may be caused by a conflict with a form or report module. For example, if you have a procedure named Report_Report1 and you also have a report named Report1, you can experience this problem.



RESOLUTION
Change the name of the procedure so that it does not match the name of a module in the database. In order to determine the module names in the database (so that you can determine what names not to use) follow these steps:


 * 1) Using Microsoft Access 97, open the database that contains the procedure you are unable to run.
 * 2) Click Options from the Tools menu.
 * 3) Check "System Objects" on the View tab.
 * 4) Click OK to close the Options dialog.

You should now see a table in the database named "MsysModules2." Open the table and view the Name field. The Name field lists all modules in the database. Make sure that you do not name a procedure with the same name as a module. Note: Do not edit the MsysModules2 table. Be sure to deselect "System Objects" on the View tab when finished viewing the MsysModules2 table.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Start Microsoft Access 97 and create a new database (such as db1.mdb). Choose Module from the Insert menu to create Module1.  Add the following code to the Module1: Public Sub Report_Report1 MsgBox "Hello" End Sub  Press the CTRL+G key combination to view the Debug Window. In the bottom pane of the Debug Window, type the following line and press Enter:

Run "Report_Report1"

The Report_Report1 procedure successfully runs. Click OK to dismiss the "Hello" message box.</li> Click on the Database Window and choose Report from the Insert menu. Click OK to create a new report in Design View.</li> Choose Code from the View menu to display the report's module.</li> Save the report as Report1.

NOTE: In Microsoft Access 97, when a form or report is created, a module is not added to the MsysModules2 table unless you have gone into the code window for the form or report and saved it.</li> Close the code and design windows for Report1.</li> Repeat steps 4 and 5 to run the Report_Report1 public procedure. You will receive the error:

Run-time error '2517': Microsoft Access can't find the procedure 'Report_Report1.'

To solve this problem, you must either rename the report or, rename the Report_Report1 procedure in Module1.</li></ol>

Additional query words: MSAccess ActiveX OLE

Keywords: kbautomation kbprb kbprogramming KB190943

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.