• Dim dbs as Database (2000)

    Author
    Topic
    #1771144

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #1790040

      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.

      • #1790045

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

        Kevin

        • #1790048

          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.

    Viewing 0 reply threads
    Reply To: Dim dbs as Database (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: