Results 1 to 4 of 4
  1. #1
    kevrizz
    Guest

    Dim dbs as Database (2000)

    Is there any reason why this code causes a compile error?
    I have tried copying code from various sources but can't seem to get past this piece of code. It's the same if I use Dim dbs as DAO.Database.
    I have to be missing something here but for the life of me I can't figure out what it is. Especially when Dim rst As Recordset is OK.
    Any advice would be appreciated.

  2. #2
    Star Lounger
    Join Date
    Nov 2001
    Location
    Illinois, USA
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dim dbs as Database (2000)

    I think I read that Access 2000 does not set a reference to the DAO object library by default; but it does set a reference to the ADO library. So if your database was created in Access 2000 you would need to set the reference explicitly; if you already did this, it may have gotten unset somehow; that sometimes happens. Without the DAD library, the compiler will still recognize Recordset because ADO has a recordset object, but it doesn't have a Database object.

  3. #3
    kevrizz
    Guest

    Re: Dim dbs as Database (2000)

    Thank you, Thank you, Thank you Dottie
    I just needed that prompt to get me back on track.
    Your advice was spot on.

    Kevin

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dim dbs as Database (2000)

    Make sure you make a habit of specifically declaring your objects as DAO.Database and DAO.Recordset, etc. If you don't and you leave both references checked, you'll probably still get a runtime error even if you don't get a compile error, because Access won't be sure which flavor of recordset you're using, and it uses the libraries in the order they're listed in references. So if ADO comes first, it will accept that Database is a DAO object but will try to evaluate Recordset as an ADO object with a different set of methods and properties than you used in your DAO code.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •