I've got a text file that the following code reads behind the splash screen to verify/update the linked table connections. For example, this line:
CC Numbers = C:\Files\Db\Lists.mdb
is read and parsed into the sTable (left side) and sFile (right side) variables to be used to set/verify the connection. However, at the line:
tdf.RefreshLink
an error occurs that reads:
'C:\Files\Db\ C:\Files\Db\Lists.mdb' isn't a valid path...
which of course it isn't, even though the following value is displayed when you hold your cursor over the preceding line (preceding tdf.RefreshLink) in debug mode:
tdf.Connect = ";DATABASE=C:\Files\Db\Lists.mdb"
Where is this doubled-up value coming from?
*******************************
Function ResetConnections() As Boolean
On Error GoTo Err_ResetConnections
Dim dbs As Database, rst As Recordset, tdf As TableDef
Dim sLine As String, sFile As String, sTable As String
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT SysObjects.Connect,_
MsysObjects.Database, MSysObjects.Name from MSysObjects " &_
"WHERE MSysObjects.Type = " & IntAttachedTableType)
If rst.RecordCount <> 0 Then
Open "C:\DPO\DPOsetup.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, sLine
sTable = Left(sLine, InStr(sLine, "="
- 2)
sFile = Mid(sLine, InStr(sLine, "="
+ 1)
rst.MoveFirst
Do While Not rst.EOF
If rst![Name].value = sTable Then
Set tdf = dbs.TableDefs(rst![Name].value)
tdf.Connect = ";DATABASE=" & sFile
tdf.RefreshLink
End If
rst.MoveNext
Loop
dbs.TableDefs.Refresh
Loop
End If
dbs.Close
Reset
Exit_ResetConnections:
Exit Function
Err_ResetConnections:
MsgBox Err.Description
Resume Exit_ResetConnections
End Function
*******************************
Thanks in advance.
Dan
CC Numbers = C:\Files\Db\Lists.mdb
is read and parsed into the sTable (left side) and sFile (right side) variables to be used to set/verify the connection. However, at the line:
tdf.RefreshLink
an error occurs that reads:
'C:\Files\Db\ C:\Files\Db\Lists.mdb' isn't a valid path...
which of course it isn't, even though the following value is displayed when you hold your cursor over the preceding line (preceding tdf.RefreshLink) in debug mode:
tdf.Connect = ";DATABASE=C:\Files\Db\Lists.mdb"
Where is this doubled-up value coming from?
*******************************
Function ResetConnections() As Boolean
On Error GoTo Err_ResetConnections
Dim dbs As Database, rst As Recordset, tdf As TableDef
Dim sLine As String, sFile As String, sTable As String
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("SELECT SysObjects.Connect,_
MsysObjects.Database, MSysObjects.Name from MSysObjects " &_
"WHERE MSysObjects.Type = " & IntAttachedTableType)
If rst.RecordCount <> 0 Then
Open "C:\DPO\DPOsetup.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, sLine
sTable = Left(sLine, InStr(sLine, "="
sFile = Mid(sLine, InStr(sLine, "="
rst.MoveFirst
Do While Not rst.EOF
If rst![Name].value = sTable Then
Set tdf = dbs.TableDefs(rst![Name].value)
tdf.Connect = ";DATABASE=" & sFile
tdf.RefreshLink
End If
rst.MoveNext
Loop
dbs.TableDefs.Refresh
Loop
End If
dbs.Close
Reset
Exit_ResetConnections:
Exit Function
Err_ResetConnections:
MsgBox Err.Description
Resume Exit_ResetConnections
End Function
*******************************
Thanks in advance.
Dan