PC Review


Reply
Thread Tools Rate Thread

dim as database

 
 
=?Utf-8?B?YW15MTQ3NzU=?=
Guest
Posts: n/a
 
      17th Mar 2006
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
 
Reply With Quote
 
 
 
 
Wayne Morgan
Guest
Posts: n/a
 
      17th Mar 2006
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

--
Wayne Morgan
MS Access MVP


"amy14775" <(E-Mail Removed)> wrote in message
news:F15FF122-7FD7-4DB4-8B4E-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      17th Mar 2006
"amy14775" <(E-Mail Removed)> wrote in message
news:F15FF122-7FD7-4DB4-8B4E-(E-Mail Removed)
> 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

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?YW15MTQ3NzU=?=
Guest
Posts: n/a
 
      17th Mar 2006
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

"Wayne Morgan" wrote:

> 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
>
> --
> Wayne Morgan
> MS Access MVP
>
>
> "amy14775" <(E-Mail Removed)> wrote in message
> news:F15FF122-7FD7-4DB4-8B4E-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
=?Utf-8?B?YW15MTQ3NzU=?=
Guest
Posts: n/a
 
      17th Mar 2006
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

"Dirk Goldgar" wrote:

> "amy14775" <(E-Mail Removed)> wrote in message
> news:F15FF122-7FD7-4DB4-8B4E-(E-Mail Removed)
> > 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
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Any solution for error message "Could not attach file 'App_Data\Database.mdf' as database 'Database'."? ornit_sagy@yahoo.com Microsoft ADO .NET 0 8th Jan 2007 09:34 PM
Any solution for error message "Could not attach file'App_Data\Database.mdf' as database 'Database'."? ornit_sagy@yahoo.com Microsoft ADO .NET 1 8th Jan 2007 09:12 PM
How to Add an All Values Item to a Database Query by Using the FrontPage 2003 Database Results Wizard =?Utf-8?B?RGFuaWVs?= Microsoft Frontpage 4 2nd Feb 2004 06:36 PM
WINS could not start due to a missing or corrupt database.Restore the database using WINS Manager (or winscl.exe found in the Windows 2000 Resource Kit) and restart WINS. If WINS still does not start, begin with a fresh copy of the database. =?Utf-8?B?V2hvcHJvZmVzc29y?= Microsoft Windows 2000 0 9th Dec 2003 10:41 PM
Help w/ The database database name needs to be repaired or isn't a database file dcollar Microsoft Access 2 18th Jul 2003 11:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:12 AM.