PRB: Error 13 Type Mismatch Error on DAO OpenRecordset Method
ID: Q181542
|
The information in this article applies to:
-
Microsoft Visual Basic Enterprise Edition for Windows, versions 5.0, 6.0
-
ActiveX Data Objects (ADO), version 2.1 SP2
-
Microsoft Visual Basic Learning and Professional Editions for Windows, versions 5.0, 6.0
-
Microsoft Access 2000
SYMPTOMS
If you dimension an object as a Recordset and then set that object to
databaseobject.OpenRecordset(source), you may get the following error
message:
Run time error '13': Type mismatch
CAUSE
If your project contains references to both the Data Access Objects (DAO)
library and the ActiveX Data Objects (ADO) library, you may see multiple
Recordset entries in the list box when you dimension the Recordset object.
This error occurs when you list the ADO library with a higher priority than
the DAO library in the References dialog box, regardless of which Recordset
entry you select from the list box.
RESOLUTION
If you need only the DAO Recordset object, make sure that the reference for
the DAO object library has a higher priority in the References dialog box,
or clear the reference to Microsoft ActiveX Data Objects.
If you need to reference and use both DAO and ADO Recordset objects,
dimension the objects explicitly as follows:
Dim adoRS As ADODB.Recordset
Dim daoRS As DAO.Recordset
MORE INFORMATION
Steps to Reproduce Behavior
- On the Project menu, select References.
- In the References dialog box, set references to both the Microsoft Data
Access Objects 3.x library and the Microsoft ActiveX Data Objects
library.
- Make sure that the ADO library appears in the list above the DAO
library.
- Place the following code in the General Declarations section of your
project:
Dim dbs AS Database
Dim rs AS Recordset ' When you press the spacebar after "AS," the
' list box includes multiple Recordset entries.
' Pick any Recordset item, or type "Recordset."
- Place this code in the Form_Load procedure:
Set dbs=OpenDatabase(dbname)
Set rs=dbs.OpenRecordset(source) ' The error occurs when this line
' of code executes.
Additional query words:
OpenRecordset DAO mismatch
Keywords : kbAccess kbADO kbDAO kbVBp500 kbVBp600 kbGrpVBDB kbDSupport
Version : WINDOWS:2.1 SP2,2000,5.0,6.0
Platform : WINDOWS
Issue type : kbprb