Why would the backend location change? Does this happen frequently?
Create a VBA function that is called by an AutoExec macro or an UNBOUND form that opens by default.
VBA like:
Code:
Dim fDialog As Office.FileDialog
Dim td As TableDef
Dim db As DAO.Database
Dim strOld As String
Dim strNew As String
Set db = CurrentDb
strOld = Mid(db.TableDefs("yourtablename").Connect, 11)
If Dir(strOld) = "" Then
' set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' restrict user to single selection in dialog box
.AllowMultiSelect = False
' Set the title of the dialog box.
.title = "Please select one file"
.InitialFileName = "C:\" 'use appropriate drive letter
' Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access file", "*.accdb"
' Show the dialog box. If the .Show method returns True, the
' user picked a file. If the .Show method returns False, user clicked Cancel
If .Show = True Then
strNew = .SelectedItems(1)
'reset backend links path
For Each td In db.TableDefs
If InStr(td.Connect, strOld) > 0 Then
Debug.Print td.Name
Debug.Print "Old Link: " & td.Connect
td.Connect = Replace(td.Connect, strOld, strNew)
td.RefreshLink
Debug.Print "New Link: " & td.Connect
End If
Next td
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End If