Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    US
    Posts
    343

    Unanswered: Dynamically Relinking Linked Tables

    My problem was that I wanted to dynamically relink all the linked tables if the path of my back end changes.

    I am using catalog Catalog colloection of ADOX and was modifying the linked datasource property to the new db path.

    The function work good on all the machines which have full microsoft office installed. It doesnot work on machines which have only the microsoft's Access runtime files.

    Any idea what should I do? or does anyone has encountered similar problem?

  2. #2
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    I pass the path and filename of the tx.mdb from another function to this fuction:

    counttables = dbs.TableDefs.count
    Forms![Message].Repaint

    Main = left(FileName, InStr(FileName, "Tx") - 1) & "Main.mdb"
    Common = left(FileName, InStr(FileName, "Tx") - 1) & "Common.mdb"
    For intCount = 0 To counttables - 1
    calcPct = Int(intCount / counttables * 100)
    Forms![Message]![Message].Caption = "Opening File (" & calcPct & "%): " & Chr(13) & Chr(10) & Chr(13) & Chr(10) & FileName
    Forms![Message].Repaint
    Set tdf = dbs.TableDefs(intCount)
    ' If the table has a connect string, it's a linked table.
    Check = tdf.Connect
    If Len(Check) > 0 Then
    tdfName = tdf.Name
    If InStr(Check, "Main") > 0 Then
    LinkFileName = Main
    ElseIf InStr(Check, "Common") > 0 Then
    LinkFileName = Common
    Else
    LinkFileName = FileName
    End If
    LinkFileName = left(Check, InStr(Check, "DATABASE") + 8) & LinkFileName

    If tdf.Connect <> LinkFileName Then
    tdf.Connect = LinkFileName
    Err = 0
    tdf.RefreshLink ' Relink the table.
    If Err <> 0 Then
    Relink = False
    Exit Function
    End If
    End If
    End If
    Next intCount

  3. #3
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    Thanks I'll try and will post the results..

  4. #4
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    Works like a charm !!!..

Posting Permissions

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