Run-time error '13': Type mismatch

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
 
S

Scott McDaniel

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

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

Top