Results 1 to 6 of 6
  1. #1
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Setting Reference Library at Database Startup (A2K SR1)

    Is it possible to set the VB reference library at database startup as well as the heirarchy in which they appear? (I.e., In VB, Select Tools, References, DAO 3.6)

    Several users have references set to ADO which cause some programming with DAO to fail. Changing the Reference Library from ADO to DAO corrects the issue.
    Regards,

    Gary
    (It's been a while!)

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

    Re: Setting Reference Library at Database Startup (A2K SR1)

    I thought that references were stored with the database. You might try the following:

    Function CorrectReferences()
    Dim ref As Reference
    On Error Resume Next
    Set ref = References("ADODB")
    If Not (ref Is Nothing) Then
    References.Remove ref
    End If
    Set ref = Nothing
    Set ref = References("DAO")
    If ref Is Nothing Then
    ' If necessary, substitute correct path below
    References.AddFromFile "C:Program FilesCommon FilesMicrosoft SharedDAODAO360.dll"
    End If
    Set ref = Nothing
    End Function

    Call this function from an AutoExec macro or from the startup form of the database. Let's hope this doesn't bite its own tail.

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

    Re: Setting Reference Library at Database Startup (A2K SR1)

    You must have at least one of those two object models referenced in order to start Access. You just fell over the reason you need to specify the object model for every model-specific object--recordsets, parameters, fields, indexes, and all DAO-specific or ADO specific objects--rather than just allowing the order of the references to control it. It takes a little work to do it in the first place, but it keeps your users from breaking the app merely by setting a reference to the other object model.
    Charlotte

  4. #4
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Setting Reference Library at Database Startup (A2K SR1)

    Thanks Charlotte.

    One question. If a machines' reference library is set to ADO only and I try to use DAO, i.e., Dim rst As DAO.Recordset, will access produce an error? (I know I could just try it but I figured I would ask.)

    Thanks for the information. Hope all is well. Happy Holidays.
    Regards,

    Gary
    (It's been a while!)

  5. #5
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Setting Reference Library at Database Startup (A2K SR1)

    Thanks Hans,

    I will give this a try (in the near future) and let you know what happened.

    Happy Holidays.
    Regards,

    Gary
    (It's been a while!)

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

    Re: Setting Reference Library at Database Startup (A2K SR1)

    Yes, but at least you'll know exactly what the problem is. If you don't declare it as a DAO recordset, ADO will try to use the ADO object and blow up on methods and properties that don't exist in ADO.
    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
  •