Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Set a reference to an external database from VBA

Discussion in 'Information Technology' started by jj, Jul 28, 2006.

  1. jj

    jj
    Expand Collapse
    Guest

    Hi

    I create a database (DB2.mdb) from another database (DB1.mdb), and then I
    export some objekts from db1 to db2. My problem is that when I try to run
    db2, it complains because it now needs the reference Microsoft DAO 3.6
    object library. So I need to set the reference in DB2 from VBA in DB1.

    TIA
    JJ
     
  2. Loading...

    Similar Threads Forum Date
    Sikh News Settlement Leads To Peaceful Transition At Sikh Temple Breaking News Sep 10, 2016
    Sikhi Langar-Aid - Sikhs Have Set Up A 'Langar' In The ISIS Territory of Syria To Feed Refugees Sikh Sikhi Sikhism Oct 31, 2015
    A set back or a step forward Blogs Oct 17, 2015
    USA Sikh Cartoonist Sets Out To Fight Racial Bias Breaking News Mar 9, 2015
    India Who says we have skeletons only in our closets? Breaking News Aug 22, 2014

  3. '69 Camaro

    '69 Camaro
    Expand Collapse
    Guest

    Hi, JJ.

    > it complains because it now needs the reference Microsoft DAO 3.6 object
    > library. So I need to set the reference in DB2 from VBA in DB1.


    Do you mean set the reference manually using the References dialog window
    from the VBA code window (VB Editor), or set the reference via VBA code? If
    it's manual, then please see the following Web page for a link to Tom
    Wickerath's article, "ADO and DAO Library References in Access Databases":

    http://www.Access.QBuilt.com/html/articles.html

    If it's via code, then try: (watch out for word wrap, as the AddFromFile
    function should be all one line)

    Public Sub addLibRef()

    On Error GoTo ErrHandler

    Dim accApp As New Access.Application

    accApp.OpenCurrentDatabase "C:\Work\DB2.mdb", True
    accApp.References.AddFromFile "C:\Program Files\Common Files\Microsoft
    Shared\DAO\dao360.dll"
    accApp.RunCommand acCmdCompileAllModules

    CleanUp:

    accApp.Quit
    Set accApp = Nothing

    Exit Sub

    ErrHandler:

    MsgBox "Error in addLibRef( )." & vbCrLf & vbCrLf & _
    "Error #" & Err.Number & vbCrLf & Err.Description
    Err.Clear
    GoTo CleanUp

    End Sub


    HTH.
    Gunny

    See http://www.QBuilt.com for all your database needs.
    See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
    http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
    info.


    "jj" <jj@get2net.dk> wrote in message
    news:eXwj6tFmGHA.4064@TK2MSFTNGP02.phx.gbl...
    > Hi
    >
    > I create a database (DB2.mdb) from another database (DB1.mdb), and then I
    > export some objekts from db1 to db2. My problem is that when I try to run
    > db2, it complains because it now needs the reference Microsoft DAO 3.6
    > object library. So I need to set the reference in DB2 from VBA in DB1.
    >
    > TIA
    > JJ
    >
     
  4. jj

    jj
    Expand Collapse
    Guest

    Hi Gunny

    It is via Code, and it works perfectly.

    Thanks a lot
    JJ
    "'69 Camaro" <ForwardZERO_SPAM.To.69Camaro@Spameater.orgZERO_SPAM> skrev i
    en meddelelse news:%23VOyeIGmGHA.2204@TK2MSFTNGP03.phx.gbl...
    > Hi, JJ.
    >
    >> it complains because it now needs the reference Microsoft DAO 3.6 object
    >> library. So I need to set the reference in DB2 from VBA in DB1.

    >
    > Do you mean set the reference manually using the References dialog window
    > from the VBA code window (VB Editor), or set the reference via VBA code?
    > If it's manual, then please see the following Web page for a link to Tom
    > Wickerath's article, "ADO and DAO Library References in Access Databases":
    >
    > http://www.Access.QBuilt.com/html/articles.html
    >
    > If it's via code, then try: (watch out for word wrap, as the AddFromFile
    > function should be all one line)
    >
    > Public Sub addLibRef()
    >
    > On Error GoTo ErrHandler
    >
    > Dim accApp As New Access.Application
    >
    > accApp.OpenCurrentDatabase "C:\Work\DB2.mdb", True
    > accApp.References.AddFromFile "C:\Program Files\Common Files\Microsoft
    > Shared\DAO\dao360.dll"
    > accApp.RunCommand acCmdCompileAllModules
    >
    > CleanUp:
    >
    > accApp.Quit
    > Set accApp = Nothing
    >
    > Exit Sub
    >
    > ErrHandler:
    >
    > MsgBox "Error in addLibRef( )." & vbCrLf & vbCrLf & _
    > "Error #" & Err.Number & vbCrLf & Err.Description
    > Err.Clear
    > GoTo CleanUp
    >
    > End Sub
    >
    >
    > HTH.
    > Gunny
    >
    > See http://www.QBuilt.com for all your database needs.
    > See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
    > http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
    > info.
    >
    >
    > "jj" <jj@get2net.dk> wrote in message
    > news:eXwj6tFmGHA.4064@TK2MSFTNGP02.phx.gbl...
    >> Hi
    >>
    >> I create a database (DB2.mdb) from another database (DB1.mdb), and then I
    >> export some objekts from db1 to db2. My problem is that when I try to run
    >> db2, it complains because it now needs the reference Microsoft DAO 3.6
    >> object library. So I need to set the reference in DB2 from VBA in DB1.
    >>
    >> TIA
    >> JJ
    >>

    >
    >
     
  5. '69 Camaro

    '69 Camaro
    Expand Collapse
    Guest

    You're welcome. Glad it helped.

    Gunny

    See http://www.QBuilt.com for all your database needs.
    See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
    http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
    info.


    "jj" <jj@get2net.dk> wrote in message
    news:ehbuIyHmGHA.3980@TK2MSFTNGP02.phx.gbl...
    > Hi Gunny
    >
    > It is via Code, and it works perfectly.
    >
    > Thanks a lot
    > JJ
    > "'69 Camaro" <ForwardZERO_SPAM.To.69Camaro@Spameater.orgZERO_SPAM> skrev i
    > en meddelelse news:%23VOyeIGmGHA.2204@TK2MSFTNGP03.phx.gbl...
    >> Hi, JJ.
    >>
    >>> it complains because it now needs the reference Microsoft DAO 3.6 object
    >>> library. So I need to set the reference in DB2 from VBA in DB1.

    >>
    >> Do you mean set the reference manually using the References dialog window
    >> from the VBA code window (VB Editor), or set the reference via VBA code?
    >> If it's manual, then please see the following Web page for a link to Tom
    >> Wickerath's article, "ADO and DAO Library References in Access
    >> Databases":
    >>
    >> http://www.Access.QBuilt.com/html/articles.html
    >>
    >> If it's via code, then try: (watch out for word wrap, as the AddFromFile
    >> function should be all one line)
    >>
    >> Public Sub addLibRef()
    >>
    >> On Error GoTo ErrHandler
    >>
    >> Dim accApp As New Access.Application
    >>
    >> accApp.OpenCurrentDatabase "C:\Work\DB2.mdb", True
    >> accApp.References.AddFromFile "C:\Program Files\Common Files\Microsoft
    >> Shared\DAO\dao360.dll"
    >> accApp.RunCommand acCmdCompileAllModules
    >>
    >> CleanUp:
    >>
    >> accApp.Quit
    >> Set accApp = Nothing
    >>
    >> Exit Sub
    >>
    >> ErrHandler:
    >>
    >> MsgBox "Error in addLibRef( )." & vbCrLf & vbCrLf & _
    >> "Error #" & Err.Number & vbCrLf & Err.Description
    >> Err.Clear
    >> GoTo CleanUp
    >>
    >> End Sub
    >>
    >>
    >> HTH.
    >> Gunny
    >>
    >> See http://www.QBuilt.com for all your database needs.
    >> See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
    >> http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
    >> info.
    >>
    >>
    >> "jj" <jj@get2net.dk> wrote in message
    >> news:eXwj6tFmGHA.4064@TK2MSFTNGP02.phx.gbl...
    >>> Hi
    >>>
    >>> I create a database (DB2.mdb) from another database (DB1.mdb), and then
    >>> I export some objekts from db1 to db2. My problem is that when I try to
    >>> run db2, it complains because it now needs the reference Microsoft DAO
    >>> 3.6 object library. So I need to set the reference in DB2 from VBA in
    >>> DB1.
    >>>
    >>> TIA
    >>> JJ
    >>>

    >>
    >>

    >
    >
     

Share This Page