Type Mismatch

J

Jim

I have avoided creating record sets, mostly because i can
never get them to work, instead i used temp tables.

I have decided to learn to use record sets if it kills
me. Well, it is.

When I run the following code I get a Type Mismatch error
on the Set rstSpecialists line, why? The table contains 2
fields SpEmail txt(50) and SpID integer.

Dim varSpecialistID As Integer
Dim rstSpecialists As Recordset
Dim strSQL As String

strSQL = "SELECT * FROM tbl_SealReh_Details"
Set rstSpecialists = CurrentDb.OpenRecordset(strSQL)
rstSpecialists.MoveLast
Debug.Print rstSpecialists.RecordCount
rstSpecialists.Close

Thanks for your help,

Jim
 
C

chas

Hi Jim,

Have you used Tools>References in the VBA editor to set a
reference to 'Microsoft DAO 3.6 Object Library'? If so,
then try modifying your code to explicitly reference a DAO
recordset:

Dim rstSpecialists As DAO.Recordset

If you haven't then I suggest that you do and then use the
syntax above.

By default a new Access database does not set this
reference but uses ADO instead and as both libraries have
a RecordSet object things can get a little confusing.

hth

chas
 
K

Ken Snell

For the code that you put in your original post, you need to use the DAO
library. DAO and ADO are two different ways of handling data via recordsets.
DAO is the older method that is still preferred by most ACCESS developers
for work within ACCESS databases (it's designed to work with the Jet engine
that handles the data), and ADO is designed for interacting with other
databases and for ODBC connections.

They're similar but different. If you're working with ACCESS only at this
time, I'd stay with DAO.
 
J

Jim

Thanks for the help. I'm working on an Access only
application so DAO it is...

Thanks,

Jim
 

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