Error: Type Mismatch

  • Thread starter Thread starter Michelle
  • Start date Start date
M

Michelle

I copied the following code from a Help Example. When
used in the Northwind database (using table name
EMPLOYEES) it seems to run fine. But, when used in my
test database on my table PERIODS, I get a type mismatch
Runtime Error '13' on the "Set rstTemp =
dbs.OpenRecordset" statement.
I don't understand what the difference is.

Private Sub TestButton_Click()
Dim dbs As Database
Dim rstTemp As Recordset
Set dbs = CurrentDb()
Set rstTemp = dbs.OpenRecordset( _
"SELECT * FROM PERIODS", dbOpenDynaset, dbReadOnly)
rstTemp.Close
dbs.Close
End Sub
 
The demon is ADO vs DAO

Make this change:

Dim rstTemp As DAO.Recordset

You may need to check your references but I think you have
DAO references (as well as ADO) because otherwise it would
bomb out on the line before (Dim dbs As Database)
 
Thank you very much. That was exactly it :)

-----Original Message-----
The demon is ADO vs DAO

Make this change:

Dim rstTemp As DAO.Recordset

You may need to check your references but I think you have
DAO references (as well as ADO) because otherwise it would
bomb out on the line before (Dim dbs As Database)


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Type mismatch error 2
Database not a recognized data type 3
Temporary recordsets 3
Type Mismatch on Opening table 4
Not recognizing specification 4
Type Mismatch 3
type mismatch 1
Carry data across (Help) 5

Back
Top