Skip to content

Instantly share code, notes, and snippets.

@notesbytom
Last active October 3, 2018 19:04
Show Gist options
  • Save notesbytom/9ae99064ec3696b627d2698df9f44aef to your computer and use it in GitHub Desktop.
Save notesbytom/9ae99064ec3696b627d2698df9f44aef to your computer and use it in GitHub Desktop.
Change ODBC Driver for Access Linked Tables
' 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