Using Recordset Objects

G

Guest

I'm working on adding multiple records once by clicking a command button in a
form, I'd like to use Recordset to add the records by using the method AddNew
and Update, but after I declared a variable like as I copied from the book:

Dim dbs As Database, rstCustomers As Recordset

Set dbs = CurrentDb
Set rstCustomers = dbs.OpenRecordset("Customers")

it said "Compile error: User-defined type not defined", is Database a system
defined object? Can I use it like this way?

Any help would be appreciated. Thanks a lot in advance.
 
G

Guest

This is DAO methods ...
Assuming you are using Access 2000 or higher, you need to enable teh
Microsoft DAO 3.6 Object Library in the application.
Also change line:
rstCustomers As Recordset
Change to:
rstCustomers As DAO.Recordset

R. Hicks
 
G

Guest

Open code, anywhere, or click Ctrl+G

From the menu bar select Tools > reference
Add from the List the Microsoft DAO 3.6 Object Library, by selecting it
 
D

Douglas J. Steele

Unless you remove the reference to ADO, you'll need to disambiguate the
declaration:

Dim dbs As DAO.Database, rstCustomers As DAO.Recordset

(It's actually not essential to disambiguate the Database declaration, but
there's nothing wrong with doing it...)

This is because objects with the same names exist in the 2 models.

The list of objects with the same names in the 2 models is Connection,
Error, Errors, Field, Fields, Parameter, Parameters, Property, Properties
and Recordset

To guarantee an ADO recordset, you'd use Dim rstCustomers As ADODB.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