ERROR 13 -- Need some Help

  • Thread starter Tim Neustel via AccessMonster.com
  • Start date
T

Tim Neustel via AccessMonster.com

Hello Board,

I know this must be a simple error but I am stumped....

Receiving Run-Time Error '13' (Type Mismatch)

Definitions:
Dim dbCustodian As Database
Dim rstUsers As Recordset

Settings:
Set dbCustodian = CurrentDb
Set rstUsers = dbCustodian.OpenRecordset("tblAuthorizedPersonnel",
dbOpenDynaset)
Thanks for any help!!
 
T

Troy

Try this instead:

1. Set a reference to DAO

Dim rstUsers As DAO.Recordset

--
Troy

Troy Munford
Development Operations Manager
FMS, Inc.
www.fmsinc.com


message Hello Board,

I know this must be a simple error but I am stumped....

Receiving Run-Time Error '13' (Type Mismatch)

Definitions:
Dim dbCustodian As Database
Dim rstUsers As Recordset

Settings:
Set dbCustodian = CurrentDb
Set rstUsers = dbCustodian.OpenRecordset("tblAuthorizedPersonnel",
dbOpenDynaset)
Thanks for any help!!
 
T

Troy

I really don't know. All I do know is that the compiler cannot handle it. I
can think of some good theoretical reasons, but don't know the exacts.

--
Troy

Troy Munford
Development Operations Manager
FMS, Inc.
www.fmsinc.com


message Thanks! Why is that??
 
T

Tim Neustel via AccessMonster.com

I could probably add to those theoretical ideas...but we will leave those
for MS to ponder at a later date :)

Thanks again!!
 
R

Rob Oldfield

Access supports both ADO and DAO objects and they both support a recordset
object. If it isn't explicitly stated which of the two it is then Access
will assume that the type is the one that has the higher priority (look at
Tools, References... the one higher up the list is the higher priority).

So your db contains both references with ADO higher. Your code comes along
and finds Dim rstUsers As Recordset and assumes that it's ADO... which
doesn't support the db.openrecordset command.
 
B

Brendan Reynolds

Just to expand a little on that - what's happening is that OpenRecordset
returns a DAO recordset, and the code is attempting to assign that DAO
recordset to a variable that has been declared (albeit implicitly, for the
reasons you give below) as an ADO recordset. A DAO recordset and an ADO
recordset may share the same name, but they are different types - hence,
type mismatch.
 
R

Rob Oldfield

Now why couldn't I put it that nicely?


Brendan Reynolds said:
Just to expand a little on that - what's happening is that OpenRecordset
returns a DAO recordset, and the code is attempting to assign that DAO
recordset to a variable that has been declared (albeit implicitly, for the
reasons you give below) as an ADO recordset. A DAO recordset and an ADO
recordset may share the same name, but they are different types - hence,
type mismatch.
 

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