dim as database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help. I am attatching a module with code in it to a calculation
command button in my access program. But I keep getting a compile error at
this line:
Dim db as Database

I don't even have Database as a type of variable available. I am confused
because everything I have read and seen shows it like this with the next line
as
Set db = CurrentDb.
I don't know why it will not let me choose Dim db as Database.
Any help would be great.
Thank You
 
In to code editor, go to Tools|References. Is one of the checked references
called "Microsoft DAO 3.6 Object Library"? If not, then scroll down the
list, check the reference, and click Ok. The error should now go away.

Access will use the list of checked references in the order in which they
are listed in the References dialog, hence the Up and Down buttons on the
dialog. There are some components of ADO and DAO that have the same name. If
Access finds the wrong one (i.e. not the one you wanted) first, it will
cause you a problem. For that reason, I recommend that all ADO and DAO items
that you Dim, that you specify which of the two they are.

Example:
Dim db As DAO.Database, rst As DAO.Recordset
rst2 As ADODB.Recordset
 
amy14775 said:
Please help. I am attatching a module with code in it to a calculation
command button in my access program. But I keep getting a compile
error at this line:
Dim db as Database

I don't even have Database as a type of variable available. I am
confused because everything I have read and seen shows it like this
with the next line as
Set db = CurrentDb.
I don't know why it will not let me choose Dim db as Database.
Any help would be great.
Thank You

You must be using Access 2000 or 2002. You need to add a reference to
the Microsoft DAO 3.6 Object Library. You can do this from the VB
Editor's Tools -> References... dialog.

Be aware that the DAO library and the (default) ActiveX Data Objects
Library both define some objects with the same names, which are not
compatible. To avoid possible confusion on the part of the VBA
compiler, either remove the reference to the ActiveX Data Objects
Library (if you won't be using it) or explicitly qualify all DAO objects
with the "DAO." qualifier, like this:

Dim db As DAO.Database
Dim rs As DAO.Recordset
 
That was it. Thank you so much. I also changed it to DAO.Database. Thanks
for the suggestion and help and saving my computer from a very ugly accident.
Thank you
 
Thank you. That was what it was. I also received the same advise on the
DAO.Database and have changed that also. Thank you, my computer really thanks
you for saving it from a horrible accident.
Thank you
 
Back
Top