Run-time error '13': Type mismatch

  • Thread starter Thread starter David Mc
  • Start date Start date
D

David Mc

I am trying to run some code to read data from a table
called tblUnit. However i keep getting the error message
Run-time error '13': Type mismatch and the line Set
rstUnit = dbsITAssessments.OpenRecordset("tblUnit",
dbOpenDynaset) is highlighted. Why?

I have the following modules installed (in VBA):

Visual Basic For Applications
Microsoft Access 9.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
ultility

My code is below:

Option Compare Database

Sub GetAssessmentInformation(strCode)

Dim dbsITAssessments As Database
Dim rstUnit As Recordset

Set dbsITAssessments = CurrentDb

Set rstUnit = dbsITAssessments.OpenRecordset
("tblUnit", dbOpenDynaset)

End Sub

Thanks

David
 
Try explicitly typing your variables:

Dim dbsITAssessments As DAO.Database
Dim rstUnit As DAO.Recordset

Also, it's a good idea to get into this habit. Cures a lot of little
problems (and I speak from experience <grin>)
 
Back
Top