VBA problem

B

bob.hinge

I'm trying to do some VBA (as per Steve Roman's Book).
I have Access 2000 and Windows Me

When I type in:

"Dim dbx as Database" (which most of the early examples start with)it
comes back with "User defined type not defined"

If I type "Dim dbx as " it comes up with a list of a few hundred
possibilities, but "Database" is not among them.

What is wrong? (I've tried reinstalling Access)
 
J

Jeff Conrad

I'm trying to do some VBA (as per Steve Roman's Book).
I have Access 2000 and Windows Me

When I type in:

"Dim dbx as Database" (which most of the early examples start with)it
comes back with "User defined type not defined"

If I type "Dim dbx as " it comes up with a list of a few hundred
possibilities, but "Database" is not among them.

What is wrong? (I've tried reinstalling Access)

No need to re-install Access.
Database is a DAO object.
By default, both Access 2000 and 2002 use ADO.

You need to set a reference to the DAO object library if you
are using Access 2000 or 2002. Those versions do not by
default set a reference to the DAO library.

To fix the References problem follow these steps:
- Open any module in Design view.
- On the Tools menu, click References.
- Scroll down to you get to Microsoft DAO 3.xx and check it.
- If you're using Access 2000, 2002, or 2003 that should be DAO 3.6 Object Library.
- Close the References box again.
- Now re-compile again. Debug--Compile.
- Hopefully you should not see any more compile errors.

As good practice it may also be better to use this:

Dim dbx As DAO.Database

....rather than:

Dim dbx As Database

This helps to avoid confusion for Access (but you still have to
manually set a reference to DAO for 2000 and 2002).

The list of objects with the same names in the ADO and DAO models
are Connection, Error, Errors, Field, Fields, Parameter, Parameters,
Property, Properties and Recordset
 
L

Larry Daugherty

You may have a references issue. What happens when you Dim dbx as
DAO.Database?

I believe it is Allen Browne who has done an excellent paper on reference
issues. You might google search on his name and the word "reference".

HTH
 
Top