Last active
October 3, 2018 19:04
-
-
Save notesbytom/9ae99064ec3696b627d2698df9f44aef to your computer and use it in GitHub Desktop.
Change ODBC Driver for Access Linked Tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Based on Stack Overflow Answer by @Fionnuala | |
' https://stackoverflow.com/questions/12606326/linked-table-ms-access-2010-change-connection-string | |
' NOTE: If a linked table is no longer valid, delete it and Restart Access or Compact the database | |
Function ChangeODBCDriver() | |
Dim tdf As TableDef | |
Dim oldDriver As String, newDriver As String | |
oldDriver = "SQL Server Native Client 10.0" | |
newDriver = "ODBC Driver 17 for SQL Server" | |
For Each tdf In CurrentDb.TableDefs | |
If tdf.Connect <> vbNullString Then | |
Debug.Print tdf.Name; " -- "; tdf.SourceTableName | |
Debug.Print " [OLD-Connect] "; tdf.Connect | |
tdf.Connect = Replace(tdf.Connect, oldDriver, newDriver) | |
Debug.Print " [NEW-Connect] "; tdf.Connect | |
tdf.RefreshLink | |
End If | |
Next | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment