General discussion


ACCESS-VBA dim as databsae

By GW0001 ·
I have a module that I am trying to create. I am trying to use a table to hold some varibles. It says that I need to dim a varible as Database. The Database option is not availible on my system. I am using Office XP Pro. Do I need to install something else?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

WHAT says

by john.a.wills In reply to ACCESS-VBA dim as databs ...

that you have to dim a variable as database?

Collapse -

Version Issue?

by talentonloan In reply to ACCESS-VBA dim as databs ...

I've run into a similar type of problem using older code samples or techniques in newer versions of Access.

The 'database' object is used in DAO (Data Access Objects) code which was standard in Access 97 I believe. Since ADO (Access Data objects) became the norm since Access 2000 and there are objects that use the same name (ie. recordset), the DAO is not by default installed. So you have to set a Reference to DAO in the application - in the VB Code side go to :

Tools - References - then check the Microsoft DAO 3.6 Object Library. Then Click OK. You should now have access to the 'Database' type of object.

Also, beware that if you declare certain types of objects as variables (ie. recordset) it will assume it is by default an ADO recordset. And when you try to run your code you will get an error. So for those object types where you are using DAO code which use names that are common to both ADO and DAO, define it as 'DAO.' ie.

Dim db as database
Dim rst as DAO.recordset

hope that makes sense


Related Discussions

Related Forums