Recordset Object

D

Dominic

Hello,

I'm using Access 2002, and trying to create a recordset
object. I've Included the "Microsoft DAO" library in my
references.

I currently have a form, table and a module setup in my
database. I have used the Onload function of the form to
call a function named Setup() which has been coded in a
module. I keep on receiving the following error "Run-Time
Error 13 - Type Mismatch", when trying to Set the
recordset. This is what my module looks like:

Option Compare Database
Public db As Database
Private rst As Recordset
Option Explicit

Function Setup()

Set db = DBEngine.Workspaces(0).Databases(0)
-> Set rst = db.OpenRecordset("tblEmployee")

End Function

Any help would be appreaciated, thanks.
Dominic
 
R

RobFMS

Change:
Public db As Database
Private rst As Recordset
Set db = DBEngine.Workspaces(0).Databases(0)

To:
Public db As DAO.Database
Public rst As DAO.Recordset
Set db = CurrentDB()

See if this resolves the error.

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
R

Roxie Aho

Starting with Access 2000, Microsoft added ADO (ActiveX
data objects). What Rob did was specify that Access is to
use the DAO (Data Access Object) library.

Roxie Aho
 

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