Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Location
    UK
    Posts
    67

    Question Unanswered: Any method to relink tables using code.

    Hi,


    I am having a front end database which is released in different servers and each database is having its own backend.

    Front End is same for multiple locations but each server has got their own backend and It takes a hell of time to connect from the front end, If we go via the Database Utilities --> Linked Tables Manager.

    Can any body please help on this?

    Thanks in Advance,

  2. #2
    Join Date
    Jul 2002
    Location
    Romania
    Posts
    122
    Sub RefreshLinks()
    Dim tdf As TableDef
    Dim newconn As String
    newconn = "\\ShareName\FolderName\FileName.mdb"
    If Len(newconn) = 0 Then
    MsgBox "You haven't selected any database. Table links will not be changed", vbInformation, "No database selection"
    Exit Sub
    End If

    On Error GoTo ErrLinks
    refreshconnection:
    newconn = ";Database=" & newconn
    For Each tdf In CurrentDb.TableDefs
    If Len(tdf.Connect) > 0 Then
    tdf.Connect = newconn
    tdf.RefreshLink
    End If
    Next
    MsgBox "Tables successfully linked"

    Exit Sub

    ErrLinks:
    Select Case Err.Description
    Case 3011
    MsgBox "The database " & Right(newconn, Len(newconn) - 10) & " does not contain the " _
    & "table '" & tdf.NAME & "'. Please select another database.", vbCritical, "Invalid database"
    Case Else
    MsgBox "Error: " & Err.Number & "-" & Err.Description
    End Select
    Exit Sub
    End Sub

    You can use the OpenDialog function from:
    http://www.mvps.org/access/api/api0001.htm
    to browse for the newconn string.

    HTH
    Dan

  3. #3
    Join Date
    Jan 2002
    Location
    UK
    Posts
    67
    Hi Danny,

    thanks a lot for you help,
    I did not know that this could be such simple.

    Still learning new things day by day.

Posting Permissions

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