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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime Error 13 type mismatch

Status
Not open for further replies.

Tomadams

Programmer
Jun 26, 2001
141
US
This code has run fine for several months not it blows up with the runtime error 13. the code is

Set DB = CurrentDb
Set rstPers = DB.OpenRecordset("tblPersonnell", dbOpenDynaset)


it blows up on the 'set rstPers' line. Any ideas???

Thanks
Tom
 
Have you checked that the ADO library is enabled in the References list?
 
I think it might be the other way around. That syntax looks like it is for DAO, not ADO. You would need to have a DAO reference selected, and, you should also declare your recordset specifically as a DAO Recordset.

Dim rstPers as DAO.Recordset

Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Tom,
It seems like you may be trying to open an ADO recordset with the DAO OpenRecordset method. Like maybe you have references to both ADO and DAO in your project, and it started defaulting to the wrong recordset type.

Try explicitly declaring rstPers object library like this:
Dim rstPers as DAO.Recordset

Tranman
 
Thanks, that was it. any ideas how it could run for a year and then start to screw up?
thanks again,
Tom
 
Dammit...you get called in to the office at zero-dark-thirty & you start to make all kinds of doofus mistakes. Brain cramp...mea culpa [morning]
 
Tom,
Just a guess, but if you have installed any Office component or update, or installed a new version of the MDAC (which could be installed with VB.Net, Visual Studio, or MANY other applications, or as a standalone update), that could have changed the order of the libraries in the registry. It's not a large leap from there to seeing how, when something is declared as just plain old recordset (without the qualifier DAO or ADODB), that it would just grab the first one it comes to and go with that.

You will see that effect if you key in:
Dim rs as
then hit the space bar and get a dropdown list of all of the different variable/object types. If you scroll down the list, you will probably see:
Recordset
Recordset
These are the ADODB and DAO recordsets, but you have no way of knowing which is which, or which you will get when you declare a Recordset unless you specify the type of Recordset in the declaration.

Hope that helps.

Tranman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top