I do something very similar. The code below is what I use. It is DAO coding as opposed to ADO. Be sure you have the Microsoft DAO 3.6 Object Library installed in your references. Put the code in a database Module, not in a form or report code sheet.
Sub ChngLink()
Dim strLink As String, tblLnkdDb As DAO.TableDef, tDefs As DAO.TableDefs
For Each tblLnkdDb In CurrentDb.tDefs
If InStr(1, tblLnkdDb.Name, "msys" = 0 Then
tblLnkdDb.Properties(4).Value = strLink
tblLnkdDb.RefreshLink
End If
Next
End Sub
Microsoft uses MSys as a prefix for all hidden system tables. You DO NOT want to link the system tables to a backend database. Each database has its own system tables.
You'll need to make modifications if only some of your tables are linked. Probably with a Select statement.
One other warning: Be sure the path to your backend is fully qualified. By that I mean, use only the absolute address of the server and the complete directory path to the backend db. Do not use a path beginning with a drive letter, as not every user may have the same drive letter mapped to that server or mapped from the same starting point on the server.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.