Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Creating links from db A to db B from db C (Access 2000)

    I have a need to be able to Link a table from database A (backend) to database B (frontend) and I want to execute this from database C.
    Help !! <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Pat

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

    Re: Creating links from db A to db B from db C (Access 2000)

    The following procedure uses DAO, so you need to set a reference to the Microsoft DAO 3.6 Object Library in Tools/References.

    <img src=/w3timages/blueline.gif width=33% height=2>

    Sub LinkTable _
    (sTargetDatabase As String, _
    sTargetTable As String, _
    sSourceDatabase As String, _
    sSourceTable As String)

    Dim dbs As DAO.Database
    Dim tdf As DAO.TableDef

    On Error GoTo Err_Handler

    Set dbs = OpenDatabase(sTargetDatabase)
    Set tdf = dbs.CreateTableDef(sTargetTable)
    tdf.Connect = ";DATABASE=" & sSourceDatabase
    tdf.SourceTableName = sSourceTable
    dbs.TableDefs.Append tdf

    Exit_Handler:
    Set tdf = Nothing
    dbs.Close
    Set dbs = Nothing
    Exit Sub

    Err_Handler:
    MsgBox Err.Number & ": " & Err.Description
    Resume Exit_Handler
    End Sub

    <img src=/w3timages/blueline.gif width=33% height=2>

    Use it as follows:

    LinkTable "C:FrontendPathB.mdb", "tblOrders_Linked", "P:BackendPathA.mdb", "tblOrders"

  3. #3
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Creating links from db A to db B from db C (Access 2000)

    Well done Hans !! <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35> <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    I couldn't quite get my mind around it, well I was nowhere near it actually. <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>
    I made a slight improvement to delete the tabledef if it was already there by testing Err.Number = 3012.

    Thank you very much indeed.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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