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)


.
 
Back
Top