You are currently offline, waiting for your internet to reconnect

ACC: Error Message "Method or Data Member Not Found"

This article was previously published under Q151572
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
SYMPTOMS
Advanced: Requires expert coding, interoperability, and multiuser skills.

When you compile a module in which a procedure is trying to call aprocedure that is defined in a class module in another database, you mayreceive the following error message:
Method or Data Member not Found.
CAUSE
Class modules are private in scope to the Visual Basic project in thedatabase in which they are defined. Therefore, procedures in class modulescannot be referenced in another Visual Basic project.

This article assumes that you are familiar with Visual Basic forApplications and with creating Microsoft Access applications using theprogramming tools provided with Microsoft Access. For more informationabout Visual Basic for Applications, please refer to your version of the"Building Applications with Microsoft Access" manual.
RESOLUTION
You can use one of the following two methods to work around this behavior.

Method 1

Store the procedure in a standard module rather than a class module. Thiswould make the procedure directly accessible from other databases but wouldrequire that you convert your class module procedures to standard moduleprocedures.

Method 2

Create a function in a standard module in the database where the classmodule is defined. This function would call the procedure from the classmodule. Then, you would call this function from a standard module ofanother database. This allows you to leave your class module procedures asis, but would require that you write a standard procedure for each classmodule procedure you want to run.
MORE INFORMATION
Although its not possible to directly call a procedure defined in a classmodule of another database from procedures outside of that database, youmay notice that it is possible to call them from the Debug window. This isbecause Visual Basic for Applications relaxes privacy rules and scoperestrictions in the Debug window to aid in debugging Visual Basicprocedures.

Steps to Reproduce Behavior

  1. Start Microsoft Access and create a new database called Class.MDB.
  2. Open a new blank form in Design view.
  3. Click Code on the View menu to view the form's module.
  4. Create the following function:
           Option Compare Database       Option Explicit       Public Function ClassModuleTest()          MsgBox "Hello"       End Function					
  5. Save and close the form as ClassForm.
  6. Close the database.
  7. Open the sample database Northwind.mdb.
  8. Open a new global module in Design view.
  9. On the Tools menu, click References.
  10. In the References dialog box, click the Browse button to browse for a new reference.
  11. In the Add References dialog box, under Files OF Type, select Databases.
  12. Select the Class.MDB database, and click OK to add it as a reference.
  13. Click OK to close the References dialog box.
  14. On the View menu, click Debug Window to open the Debug Window.
  15. Type the following line in the Debug window, and then press ENTER.

    In Microsoft Access 97:
    ? [Class].Form_ClassForm.ClassModuleTest()
    In Microsoft Access 7.0:
    ? [Class.MDB].Form_ClassForm.ClassModuleTest()
    Note that the procedure runs and the "Hello" message box is displayed.
  16. Create the following function:

    In Microsoft Access 97:
           Public Function RunClassProc()       Dim x       x = [Class].Form_ClassForm.ClassModuleTest()       End Function						
    In Microsoft Access 7.0:
           Public Function RunClassProc()       Dim x       x = [Class.MDB].Form_ClassForm.ClassModuleTest()       End Function					
  17. Try to compile the procedure by clicking Compile Loaded Moduleson the Run menu. Note that you receive the following error message:
    Method or Data Member not Found.
REFERENCES
For more information about creating references to other databases, searchthe Help Index for "Referencing, Other Databases," or ask the MicrosoftAccess 97 Office Assistant.

For more information about class modules, search the Help Index for "ClassModules," or ask the Microsoft Access 97 Office Assistant.
Properties

Article ID: 151572 - Last Review: 01/19/2007 17:46:25 - Revision: 3.3

  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition
  • kberrmsg kbprb kbprogramming KB151572
Feedback