Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch error on OpenRecordset 1

Status
Not open for further replies.

bjm1335

Programmer
Jan 25, 2002
44
US
My SQLStmt is:

SELECT EmpNbr, LastName, FirstName FROM Employees

All three fields are defined as text in the DB.
When I:

Set mrst = mdbs.OpenRecordset(SQLStmt)

I get a type mismatch error. What could cause that ?

Thanks from a newbee.
 
I think the problem is in the code before you get to the bits you've posted.

Let us see all the
Dim mdbs As Database
etc.

because I think that is where the problem lies.



G LS
 
In the Declarations:

Private Const mcstrSQL as String = "SELECT " & _
"EmpNbr, LastName, FirstName FROM Employees;"
Private Const mcstrDBName As String = "\pii.mdb"

Private mdbs As Database
Private mrst as Recordset

In the sub:

set mdbs = OpenDatabase(App.Path & mcstrDBName)
set mrst = mdbs.OpenRecordset(mcstrSQL)

I'm getting the error on the OpenRecordset

Thanks
 
Do you have references set to both the ADO and DAO libraries? If so, then the line
Private mrst as Recordset
is ambiguous, as it could be either an ADO or DAO recordset. The type mismatch error indicates that the compiler thinks mrst is an ADO recordset, when it should be a DAO recordset. You can fix this by either changing the priority of the references (the ugly way), or by declaring the recordset like this:
Private mrst as DAO.Recordset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top