I have a database that has linked tables in it from two different data sources. The tables from the first data source begin with SAC_ the tables from the second data source begin with STO_. What I have go so far is:
Function refreshLinks() As Boolean
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Len(tdf.Connect) > 0 Then
tdf.Connect = "ODBC;DSN=;UID=;PWD="
Err = 0
On Error Resume Next
tdf.RefreshLink
If Err <> 0 Then
refreshLinks = False
MsgBox "Error..... '" & tdf.Name & "'", vbOKOnly Or vbExclamation, "Error"
Exit Function
End If
End If
Next tdf
refreshLinks = True
End Function
My problem is that I need to connect to a different DSN (same username and password) for each table "prefix". Any suggestions?
Function refreshLinks() As Boolean
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Len(tdf.Connect) > 0 Then
tdf.Connect = "ODBC;DSN=;UID=;PWD="
Err = 0
On Error Resume Next
tdf.RefreshLink
If Err <> 0 Then
refreshLinks = False
MsgBox "Error..... '" & tdf.Name & "'", vbOKOnly Or vbExclamation, "Error"
Exit Function
End If
End If
Next tdf
refreshLinks = True
End Function
My problem is that I need to connect to a different DSN (same username and password) for each table "prefix". Any suggestions?