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

ID: Q190943


The information in this article applies to:
  • Microsoft Visual Basic for Applications version 5.0
  • Microsoft Access 97


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 <procedure name>. 


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_<form name> if the module is for a form, or Report_<report name> 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.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Start Microsoft Access 97 and create a new database (such as db1.mdb).


  2. Choose Module from the Insert menu to create Module1.


  3. Add the following code to the Module1:
    
    Public Sub Report_Report1
      MsgBox "Hello"
    End Sub 


  4. Press the CTRL+G key combination to view the Debug Window.


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


  6. Click on the Database Window and choose Report from the Insert menu. Click OK to create a new report in Design View.


  7. Choose Code from the View menu to display the report's module.


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


  9. Close the code and design windows for Report1.


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


Additional query words: MSAccess ActiveX OLE

Keywords : kbAccess97 kbAutomation kbVBp kbDSupport kbVBA500
Version : WINDOWS:5.0,97
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: April 27, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.