Programmatically, the basic idea is this:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim sConnect As String
Dim sName As String
sConnect = ";DATABASE=C:\SomePath\SomeFile.mdb"
Set db = CurrentDb()
For Each tdf In db.TableDefs
With tdf
sName = .Name
If .Connect <> vbNullString Then
If Not (Left$(sName, 4) = "MSys" Or Left$(sName, 1) = "~") Then
.Connect = sConnect
.RefreshLink
End If
End If
End With
Next
Set tdf = Nothing
Set db = Nothing
There is an example in Microsoft's sample database named solutions.mdb of
how to pop up the Windows File Open dialog for the user to locate where the
back end file is is located, and reconnect. Download from:
http://msdn.microsoft.com/library/officedev/bapp2000/mdbdownload.htm
As an example for the batch file, if you needed to simulate a T: drive on
your local PC the batch file would contain something like this:
subst T: C:\SomePath
Then in the AutoExec macro of your database, you would RunCode the Init()
procedure to execute the batch if it has not already been run this session:
Public Function Init()
Dim strFile As String
strFile = "C:\SomePath\AssignTDrive.bat"
If IsBadDrive Then
Application.FollowHyperlink strFile
End If
End Function
Private Function IsBadDrive()
Dim Dummy As Variant
On Error Resume Next
Dummy = Dir("T:\")
IsBadDrive = (Err.Number <> 0&)
End Function