Type mismatch opening a Recordset

D

David Portwood

This was my first attempt to open a DAO recordset. Several problems, one
still unresolved.

Code that fails:

Dim db as Database
Dim rstLog as Recordset

Set db = CurrentDb()
Set rstLog = db.OpenRecordset("Log")

I'm getting a "Type Mismatch" error from the last Set statement.

I also tried
Set rstLog = db.OpenRecordset("Log", dbOpenDynaset)

That didn't work either. My Log table is just a table. It has a primary key.

I added a reference to the DAO Objects library (I think it was 3.6) which
resolved another problem. Is there something else I need to do? Maybe use
dot notation somewhere, e.g.,

Dim rstLog as DAO.recordset?

Does anybody see what might be wrong here? Very frustrating. Has to be
something simple but I can't find it.
 
6

'69 Camaro

Hi, David.
Does anybody see what might be wrong here? Very frustrating. Has to be
something simple but I can't find it.

"Data type mismatch" occurs when the Recordset object hasn't been
disambiguated ("Is it the DAO or ADO Recordset?") in the declaration
statement, so Access assumes the library with precedence (which is the one
highest in the library references list). Please see Access MVP Tom
Wickerath's tutorial on ADO and DAO libraries on the following Web page for
a good explanation of the problem and how to fix it:

http://www.Access.QBuilt.com/html/ado_and_dao.html

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
D

David Portwood

I was completely unaware of all this. Thank you very much. And thank God for
this newsgroup!
 

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