E
ecovindaloo
I'm trying to relink tables using code to a network server. The problem is
that the users all have different letters for their server. I'm using the
following code:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim b As Boolean
Dim strPath As String
Dim dbPath As String
Dim dbname As String
On Error GoTo RelinkTables_Error
b = True
Set db = CurrentDb
dbname = "AboveDB_be.mdb"
dbPath = "\\eastfps00\accesswork\"
strPath = dbPath & dbname
'strPath = DB_PATH & DB_NAME
'Relink each table's connection string
For Each tdf In db.TableDefs
Call SysCmd(acSysCmdSetStatus, "Checking " & tdf.Name & " ...")
If (tdf.Attributes And dbAttachedTable) = dbAttachedTable Then
If Left(tdf.Connect, 7) = "Paradox" Then
'Just ignore the link because it's a Paradox table.
Else
Call SysCmd(acSysCmdSetStatus, "Relinking " & tdf.Name & " ...")
'tdf.Connect = ";" & strPath
tdf.Connect = ";DATABASE=" & strPath
tdf.RefreshLink
End If
End If
Next
I thought that by using two slashes at the front this gets around the problem
of having different network drive letters. But I get an error message and it
doesn't relink the tables.
Any ideas how to get around this problem?
that the users all have different letters for their server. I'm using the
following code:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim b As Boolean
Dim strPath As String
Dim dbPath As String
Dim dbname As String
On Error GoTo RelinkTables_Error
b = True
Set db = CurrentDb
dbname = "AboveDB_be.mdb"
dbPath = "\\eastfps00\accesswork\"
strPath = dbPath & dbname
'strPath = DB_PATH & DB_NAME
'Relink each table's connection string
For Each tdf In db.TableDefs
Call SysCmd(acSysCmdSetStatus, "Checking " & tdf.Name & " ...")
If (tdf.Attributes And dbAttachedTable) = dbAttachedTable Then
If Left(tdf.Connect, 7) = "Paradox" Then
'Just ignore the link because it's a Paradox table.
Else
Call SysCmd(acSysCmdSetStatus, "Relinking " & tdf.Name & " ...")
'tdf.Connect = ";" & strPath
tdf.Connect = ";DATABASE=" & strPath
tdf.RefreshLink
End If
End If
Next
I thought that by using two slashes at the front this gets around the problem
of having different network drive letters. But I get an error message and it
doesn't relink the tables.
Any ideas how to get around this problem?