Opening recordsets in forms

M

Marta

I am coding in the open event of a form.
When I try to open a recordset from table in my database:

Dim wrkJet As Workspace
Dim midb As Database
Dim cfbh As Recordset
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set midb = wrkJet.OpenDatabase("c:\qrx\refills62000.mdb")
Set cfbh = midb.OpenRecordset("cfbh", dbopentable)

It returns: Run-time error '13'
type mismatch

Why a type error?
 
K

Ken Snell

Chances are that you're using ACCESS 2000 or 2002. These versions do not
have a reference to DAO library set as a default library. You need to go
into Tools | References (from VBE) and select Microsoft Data Access Objects
3.x library from the list.

Then disambiguate the Dims so that ACCESS doesn't think you want
ADODB.Recordset instead of DAO.Recordset:

Dim midb As DAO.Database
Dim cfbh As DAO.Recordset
 

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