Weird Data Type Error

J

JohnV

I have a problem when I make the following declaration:

dim db as database

In some databases that I create I get an error at this
line stating "Compile Error" "User-defined type not
defined". It seems to be hit and miss as I have many
modules in other databases where this works. It also
happens on different machines (1 Winnt 4.0 and the other
Win 2000).

Any pointers would be helpful.
 
M

Marshall Barton

JohnV said:
I have a problem when I make the following declaration:

dim db as database

In some databases that I create I get an error at this
line stating "Compile Error" "User-defined type not
defined". It seems to be hit and miss as I have many
modules in other databases where this works. It also
happens on different machines (1 Winnt 4.0 and the other
Win 2000).

You don't have a reference to DAO in that database. A2K and
later default to using ADO for new databases, so you have to
set it yourself. While you're at it, if you have no plans
to use ADO, un-check that reference.
 
J

John Vinson

dim db as database

In some databases that I create I get an error at this
line stating "Compile Error" "User-defined type not
defined".

Access 200x defaults to the ADO object model, which does not have a
Database object; this code assumes the older (and IMHO still
preferable for performance and simplicity) DAO object model.

On the affected databases open the VBA editor and select Tools...
References. If you won't be using ADOX uncheck the "Microsoft ActiveX
Data Objects" reference; scroll down to "Microsoft DAO x.xx Object
Library" (highest version, probably 3.6) and check it.
 
T

Tracey Meyer

In Office 2000 and XP, you have to declare the type of
database. DAODB or ADODB. Depending on your project you
need to choose the one that applies. ADOCB can be used
with both the jet and a sql engines.

If you are using Accessv 97, then make sure that you
delcared "Dim db as Database" and that you have set it
something: "Set db = currentdb"

If you had a Access 97 db and converted it to Access 2000
or XP: I haven't figured out why however some of my
databases converted just fine and others didn't convert at
all. Usually the ones with the engine option as described
earlier.

Feel free to email me, I would be curious if I helped.


Trace
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top