6/29/2012

MS Access: Database variable "not defined" error in Access 2003/XP/2000/97

Question: I'm running an Access 2003/XP/2000/97 database with some VBA code in it.
Within the VBA code, a database object is declared as follows:




Dim db As Database
When this code is encountered, Access highlights the line and I receive the following error message:
Compile error:
User-defined type not defined
I've seen this code work in other Access databases. How come it does not work in mine?
Answer: This error often appears in Access 2000 version databases and higher. The error message looks like this:


To correct the problem, you need to open your Access database. Press Alt-F11 to open the Microsoft Visual Basic window. When the Microsoft Visual Basic window appears, select References under the Tools menu.
The References window should appear. Scroll down until you find the option called "Microsoft DAO 3.6 Object Library" and check this item. Then click on the OK button.


Now your Access database should recognize the database object and the error message should disappear. Source:techonthenet

No comments:

Post a Comment