Error: Type Mismatch

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
 
M

Media Lint

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)
 
M

Michelle Taylor

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
Type Mismatch on Opening table 4
Temporary recordsets 3
Not recognizing specification 4
type mismatch 1
Type Mismatch 3
Carry data across (Help) 5

Top