Getting Type Mismatch on OpenRecordset -- ??

P

plh

Based on all the help files I really thought I had this right: (MS Access 97)

Sub FillToolTable()

Dim rstT As Recordset
Dim dbC As Database
Dim l As Long

Set dbC = CurrentDb


Set rstT = dbC.OpenRecordset("JobTools")

This last line generates "Type Mismatch"
"JobTools" is a Table withing the Current DB. At this time it has no data
entered into it.
I have the feeling it is something very simple that I am just not seeing.
Thank You!
-plh
 
J

John W. Vinson

Based on all the help files I really thought I had this right: (MS Access 97)

Sub FillToolTable()

Dim rstT As Recordset
Dim dbC As Database
Dim l As Long

Set dbC = CurrentDb


Set rstT = dbC.OpenRecordset("JobTools")

This last line generates "Type Mismatch"
"JobTools" is a Table withing the Current DB. At this time it has no data
entered into it.
I have the feeling it is something very simple that I am just not seeing.
Thank You!
-plh

Check your references (Tools... References in the VBA editor window). There
are two different kinds of recordsets from different object libraries: DAO and
ADO. Both libraries have a Recordset object but they are DIFFERENT recordset
objects. The dbC.OpenRecordset method will return a DAO recordset. However, if
you have the ADO library checked and it's seen first (either because it's
before DAO or because DAO is unchecked) you'll get a conflict because the
function is returning a DAO recordset and trying to put it into an ADO object.

Change the Dim to

Dim rsT As DAO.Recordset

or (if you're not using ADO for other reasons) uncheck the ADO library.
 

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

Similar Threads


Top