Relink question



I'm not sure this is where to post this question, but here it is anyhow. Somebody who was working with me a while ago came up with the following code to relink back end files. I don't know if it is adapted from the code at the mvps web site, or what exactly. Tables may be in more than one BE database. In particular, the Employee table is used by a number of applications. I don't want to present the user with any options, as most users wouldn't know what to do if presented with something like the Linked Table Manager, or for that matter if asked whether they want to relink the tables. Rather, I want the code to run invisibly on startup. The BE files will not move, and I have used UNC paths to the BE files.

I have used the code below, which I call in the startup form's Load event, and have not had a problem with users not being able to get at the data. Debug.Print lists the tables and the paths correctly. I wonder, though, if I am leaving out something, as other code I have seen for relinking the BE files seems to be rather more complex than this.

Public Function RelinkBE() As Boolean

On Error GoTo ProcError

Dim tdf As TableDef
Dim strMsg As String, strCall As String

strCall = vbCrLf & "Contact tech support."

RelinkBE = True

For Each tdf In CurrentDb.TableDefs
If Len(tdf.Connect) > 0 Then
Debug.Print tdf.Name & " " & tdf.Connect
tdf.RefreshLink
End If
Next tdf
Set tdf = Nothing

ProcExit:
Exit Function

ProcError:
Select Case Err.Number
Case 3011 'Bad Table Name
strMsg = "Table Not Found." & strCall
Case 3024 'File Name Not Found
strMsg = "Database File Name Not Found." & strCall
Case 3044 'Path Not found
strMsg = "Database Path Not Found." & strCall
Case Else
strMsg = "Error " & Err.Number & " (" & Err.Description & _
") in function ReLinkBE of Module mdlRelink" & strCall
End Select

MsgBox strMsg, vbExclamation, "Call Support"
RelinkBE = False

Resume ProcExit

End Function

.



Relevant Pages

  • Re: Relink question
    ... choose that, instead of the backend. ... Public Function RelinkBE() As Boolean ... For Each tdf In CurrentDb.TableDefs ...
    (microsoft.public.access.formscoding)
  • Re: Relink question
    ... Public Function RelinkBE() As Boolean ... Dim strMsg As String, strCall As String ... For Each tdf In CurrentDb.TableDefs ...
    (microsoft.public.access.formscoding)
  • Re: Relink question
    ... I have seen code, such as at the mvps web site, to refresh table links, but message boxes asking the user if they want to refresh the links, etc. are out of the question. ... Public Function RelinkBE() As Boolean ... For Each tdf In CurrentDb.TableDefs ...
    (microsoft.public.access.formscoding)