• Setting an object as a database

    Author
    Topic
    #356307

    I’m trying to run a NotInList event that would allow the user to add an item that isn’t in the list.

    There is a line that is giving me the fits:

    Dim dbsInventory As Database

    When I type “Dim dbsInventory As” there is an object browser window that “pops up” and it doesn’t list Database as an option.

    Why?

    Viewing 0 reply threads
    Author
    Replies
    • #527071

      What version of Access are you using?

      • #527072

        I’m using Access 2000

        • #527132

          Database is a DAO object. If you don’t have a DAO reference set, you won’t see it or be able to use it.

          If you do set the DAO reference, you should also start specifying the object model in your declarations to avoid confusing Access/Jet about which model the object belongs to. So dim dbs as DAO.Database, dim rst as DAO.Recordset, etc., keeps Access from losing its mind. There are objects that have the same name between the two models (like Recordset, Field, Parameter, Property) that are very different and have different methods and properties between the two object models. If you don’t specify, the code may compile but it is likely to break at runtime.

          There are also very different objects between the models (i.e., DAO has querydefs but ADO has query objects), so specifying helps you as a programmer remember what you were doing and keeps you from mixing the two models in the same routine, an action that is likely to get you a quick trip back to the Windows desktop without even an error message in between.

          • #527254

            I am familiar with the DAO object model but am feeling more and more out of touch because of my lack of knowledge and experience with the DAO object model. Forgive me if this has been asked before but could you recommend a path for someone who needs to catch up? TIA

            • #527291

              There are a bunch of books on ADO, but virtually none on ADO in Access. The Access 2000 Developer’s Handbook (Vol 1:Desktop Edition) devotes over 130 pages to nothing but ADO with Access, plus most of the examples in both volumes use ADO code, but I haven’t found a book that goes further than that.

              However, if you’re at all familiar with VB, a couple of good ADO books are William Vaughn’s “ADO Examples and Best Practices” and Mike Gunderloy’s “The Visual Basic Developer’s Guide to ADO”. I like Mike’s book better for the way it handles some of the more exotic ADO concepts like Shaped recordsets, but both of them are worth having. Most of the code can be pasted into Access and work just fine, but of course samples are all in VB6.

            • #527703

              Thanks a lot for your recommendations, Charlotte. I’ll look them up on my next trip to the bookstore!

    Viewing 0 reply threads
    Reply To: Setting an object as a database

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

    Your information: