Here is part of what I use, and it may get you close. My full code also
includes a browse button so the user can browse to the new back end, but here
is the germane portion. If it does not work because I have missed a variable
declaration or something, I may have to just send you the whole form that I
use
Private Sub ButtonReLink_Click()
Dim FilePathData as String
FilePathData = "\\MyServer\MyShare\MyDBFolder\MyDB.mdb" 'path to back end
'open DB connection before re-link to make it faster
Dim dbData As DAO.Database
Set dbData = OpenDatabase(FilePathData)
're-link
Set dbProgram = CurrentDb
txtStatus = SysCmd(acSysCmdInitMeter, "Refreshing Links...",
dbProgram.TableDefs.Count)
For TableCount = 0 To dbProgram.TableDefs.Count - 1
If dbProgram.TableDefs(TableCount).Connect <> "" Then
dbProgram.TableDefs(TableCount).Connect = ";DATABASE=" &
FilePathData & ""
dbProgram.TableDefs(TableCount).RefreshLink
txtStatus = SysCmd(acSysCmdUpdateMeter, TableCount)
End If
Next TableCount
StatusReset
'close DB connection
dbData.Close
Set dbData = Nothing
End Sub