Microsoft KB Archive/138018

= ACC: "A Module Is Not a Valid Type" Compile Error Message =

Article ID: 138018

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q138018



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you compile a database in Microsoft Access 7.0 or 97, you may receive the following error message:

A Module is not a valid type.



CAUSE
The module has the same name as a Microsoft Access object or a data access object, and it contains a variable declared as the same object type as its name. For example, if the module is named Form, you will receive the error message if any of the module's procedures contains a form variable such as the following:

Dim f as Form



RESOLUTION
Rename the module to a name other than a Microsoft Access object name or a data access object name.



STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 7.0 and 97.



Steps to Reproduce Problem
 Start an earlier version of Microsoft Access (version 1.x or 2.0) and create a new database.  Create a module and type the following line in the Declarations section:

      Option Explicit   Type the following procedure:

Function Test(F as Form) msgbox "Form Name: " & F.Name End Function  Save the module and name it Form.</li> Close the database and quit the earlier version of Microsoft Access.</li> Start Microsoft Access 7.0 or 97.</li> On the Tools menu, point to Database Utilities, and then click Convert Database.</li> In the "Database to Convert From" dialog box, select the database created in step 1, and click the Convert button.</li> In the Convert Database Info box, enter a file name and click Save.</li> Open the converted database after the conversion process has completed.</li> In the Database window, click the Modules tab.</li> Open the module named Form in Design view.</li> On the Run menu, click Compile All Modules. Note that you receive the following error message:

A Module is not a valid type.

</li></ol>

<div class="references_section">