Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to VBA and cant use Dim db as Database

Status
Not open for further replies.

newboy18

MIS
Apr 11, 2003
45
GB
I am reading through a VBA book and it asks me to type:
Dim bd as Database
Dim rec as Recordset
As I type I get popups for recordset but not for Database, If I try to run the code it gives me an error "User-defined thpe not defined.
The book comes with examples that include these basic statments and they are OK. I am stuck and dont know why this is happening, would someone please shed some light.
 
Assumption....You are using Access 2000 or Access XP

Solution: Access 2000/XP uses ADO, instead of DAO and therefore Database is not a declared type....

in your code, use:

Dim db As DAO.Database
Dim rst as DAO.recordset

And also make sure you have the Microsoft 3.51 DAO objects checked as a reference in your reference list. If we knew what it was we were doing, it would not be called research, would it? - Albert Einstein [atom]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Try:
Dim db As DAO.Database
Dim rs As DAO.Recordset

If no result, open any module, go to Tools-References and check Microsoft DAO 3.6. Object Library

That should solve the problem.
It seems your VBA book is older than the VBA version you use.
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Thanks fo that, it looks like I just wasted £30
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top