By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,662 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,662 IT Pros & Developers. It's quick & easy.

"Dim db as Database" generates an error

P: n/a
For some reason, "Database" isn't recognised by Access as a
built-in/predefined type, in Access' own VBA. Whenever I try to compile
a line like

Dim db as Database

I get the complaint that that user defined type ("database") isn't
defined. This happens both in Access 97 (on Win98) and in Access 2000
(on XP). I seem to recall this used to work on Access 2. For the rest,
Access works normally.

CurrentDB does seem to work, but I need to be able to pass a database as
a parameter, as I'm trying to relink tables to a moved/renamed .mdb file
by code, as is done in this sample code:

<http://www.mvps.org/access/tables/tbl0009.htm>

What also isn't recognised, is the constant "dbOpenForwardOnly", as
wanted by the dbOpenRecordset method.

Did I forget to install something? I did a scan for "DAO360.dll", as
some sources would suggest I need, and I could only find copies in
strange subdirectories of the Windows directory, "ServicepackFiles" and
"SoftwareDistribution", which strikes me as odd. And only on XP.

On Win98 I find a DLL called DDAO35.DLL which is in the System
subdirectory, which seems normal. Nevertheless, it still doesn't work.

What am I missing?

--
Bart.
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Bart Lateur <ba*********@pandora.be> wrote:
I get the complaint that that user defined type ("database") isn't
defined. This happens both in Access 97 (on Win98) and in Access 2000
(on XP). I seem to recall this used to work on Access 2. For the rest,
Access works normally.


Sounds like you're missing a DAO library reference. It's also good practice
to qualify the statement:

Dim db as DAO.Database

Regards,
Keith.
ww.keithwilby.com
Nov 13 '05 #2

P: n/a
Bart Lateur wrote:
For some reason, "Database" isn't recognised by Access as a
built-in/predefined type, in Access' own VBA. Whenever I try to compile
a line like

Dim db as Database

I get the complaint that that user defined type ("database") isn't
defined. This happens both in Access 97 (on Win98) and in Access 2000
(on XP). I seem to recall this used to work on Access 2. For the rest,
Access works normally.


My suggestions:

Check your references (debug window, menu Tools->References) and uncheck
any marked as missing.

Put an explicit DAO.Database in your declaration

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #3

P: n/a
Bas Cost Budde wrote:
My suggestions:

Check your references (debug window, menu Tools->References) and uncheck
any marked as missing.
Bingo. "Microsoft DAO" wasn't checked (= available). Checking that fixed
it.
Put an explicit DAO.Database in your declaration


That, by itself, didn't help.

Thanks a million. That propblem has been nagging me for days.

--
Bart.
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.