Why "type mismatch"

Hi,

Can someone please tell me why the fiollowing code is producing a Type Mismatch (13) error:

Thanks alot!!!
Andy
---------------------
Option Explicit
Dim dbFreight As Database
Dim rsRateTable As Recordset

Private Sub Form_Load()
Set dbFreight = DBEngine.Workspaces(0).OpenDatabase _
("c:\freightsystem\accessdbs\prodfreightmaster.mdb", , True)

Set rsRateTable = dbFreight.OpenRecordset("Select [weight] from [tstRateEngine]")

---------------------------
LVL 2
abruskoAsked:
Who is Participating?
 
deightonConnect With a Mentor Commented:
U should have DAO reference, you are correct.

Try

Option Explicit
Dim dbFreight As DAO.Database
Dim rsRateTable As DAO.Recordset

Private Sub Form_Load()


Set dbFreight = DBEngine.Workspaces(0).OpenDatabase _
etc...


I got you code to work,  which of the lines is the error on?
0
 
mcmahon_sCommented:
You don't have a reference to the ADO library set do you?
0
 
abruskoAuthor Commented:
No, I don't.  I have a reference to DAO 3.51.  What should I have?

Thanks,
Andy
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
abruskoAuthor Commented:
No, I don't.  I have a reference to DAO 3.51.  What should I have?

Thanks,
Andy
0
 
deightonCommented:
Hit F2 & search for 'Recordset', you've probably got some other sort of recordset - but the
..as DAO.Recordset
prefix will sort it out.
0
 
abruskoAuthor Commented:
Deighton...the DAO prefix did it.  Thank you very much!

Andy
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.