Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Reference (XP)

  1. #1
    New Lounger
    Join Date
    Sep 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reference (XP)

    I just installed Office XP and am trying to use an Access database created in Access 2000. My VBA code doesn't compile now but did in Access 2000. I suspected that I needed to add one or more Reference libraries. I started adding ones that I thought were needed and I did get rid of the compile error for a form control, but now get a compile error stating that "User-defined type not defined." I tried adding some other References but haven't come across the right one yet. Is there any way to determine which libraries I need so I don't have to play the guess and miss game? Also, I used to be able to search the Lounge for what I was looking for but haven't found how to do a search. Did they remove that feature? Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reference (XP)

    The search feature has had to be disabled temporarily (but for quite a while now) because of server overload.

    If you tell us what is highlighted when you get the 'User-defined type not defined' error, somebody will probably be able to help you. When you first looked at the references, were any marked MISSING? That should give a clue as to which ones you need...

  3. #3
    New Lounger
    Join Date
    Sep 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference (XP)

    Dim dbs As Database ("dbs As Database" is highlighted.

  4. #4
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference (XP)

    Hi Dale...

    You have to tell it whether you want it to be a DAO.Database or ADO.Database...
    HTH

  5. #5
    New Lounger
    Join Date
    Sep 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference (XP)

    Thanks. That helped but now I get an "Method or data member not found " for the following statement:

    rstCourse.FindFirst "[Course No] = """ & [Forms]!<training Management Form>![Course Number] & """" ("![Course Number]" is highlighted.)

  6. #6
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference (XP)

    Same thing Dale... Where you are declaring rstCourse as a recordset, add DAO. in front of recordset...
    Dim rstCourse as DAO.recordset

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference (XP)

    How about setting a reference to Microsoft DAO 3.6 Object Library

    1. Go Modules
    2. Select New
    3. Select Tools, References

    HTH

    John

  8. #8
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference (XP)

    Hmmm... Is this something I've never put together John? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>
    By setting the reference, you don't need to designate DAO. ??
    I thought you always had to in the later versions of Access, reference or not...

  9. #9
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Reference (XP)

    I believe the answer is that you can avoid having to designate DAO. if you uncheck the Reference to the ADO library. My XP databases (in Access 2000 format) don't have the DAO designations and don't generate errors, but I've deleted that Reference (which gets checked by default in Access 2000).

  10. #10
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference (XP)

    Ahhhhh.... Now that would make sense...
    Thanks Steve... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reference (XP)

    It is true that if you have a reference ONLY to the DAO library, and not to ADO, you are not required to prefix every declaration of a DAO object with DAO.
    Similar if you have a reference ONLY to ADO, not to DAO: you don't have to prefix ADO objects with ADODB.

    BUT ...

    I still recommend using the prefix. If you ever need to use both ADO and DAO in your database, or if you copy your code to another database, you won't have to worry about confusion. When I was still using Access 97, I read about this issue in Woody's Lounge, and I made it a habit always to prefix DAO declarations. I'm using Access 2002 now, and when I import a form or report or module from an old Access 97 database into a new one, I either get an error message (if I haven't set a reference to DAO) or the code works without further "ado" (pun intended). If I hadn't used the DAO prefixes, I might have run into unexpected errors.

  12. #12
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reference (XP)

    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> Luv the pun...

    Thanks Hans! <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    As always, you are wonderful to share your wisdom...

  13. #13
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Reference (XP)

    I've just done some supplemental fooling around and believe I've made the following (potentially useful) discovery. (Well, "discovery" to me, anyway.)

    I went back to two Access 2000 databases that use DAO (without the DAO. designations) and in which I'd unchecked the ADO 2.1 library reference that's checked by default in A2000, and I re-checked the reference to ADO 2.1. And now the code with non-DAO-designated DAO objects compiles and runs with no errors. I'm guessing what this means is that, if you have references to both DAO and ADO libraries, Access will assume DAO or ADO for an undesignated object depending on which library appears highest in the References list.

    If anyone else experiments and gets different results (or has a different explanation), I'd be interested in hearing about it.

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Reference (XP)

    It is correct that Access tries to resolve references by walking the References list from top to bottom. So if you have a reference to DAO above (higher than) a reference to ADO, a declaration Dim rst As Recordset will be interpreted as a DAO recordset. But I wouldn't want to depend on this, so I still prefer being explicit. In the few cases where you deliberately want to be vague about which type you mean, it is safer to use Dim rst As Object.

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

    Re: Reference (XP)

    I agree, Hans. Even in a database where we use nothing but DAO and have no intention of using ADO, I still make all my declarations model-explicit. In XP especially, there is a certain amount of DAO and ADO support built right in, even without a reference set to the library, so those nasty messages can pop up regardless.
    Charlotte

Page 1 of 2 12 LastLast

Posting Permissions

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