Return to Snippet

Revision: 45579
at May 4, 2011 12:35 by huangsb


Initial Code
Option Compare Database

Public Sub RefreshODBCLinks(Optional newConnectionString As String)
    Dim db As DAO.Database
    Dim tb As DAO.TableDef
    Set db = CurrentDb
    Debug.Print "Refreshed ODBC table: "
    For Each tb In db.TableDefs
        
        If Left(tb.Connect, 4) = "ODBC" Then
            If Len(Trim(newConnectionString)) > 0 Then
                tb.Connect = newConnectionString
            End If
            tb.RefreshLink
            Debug.Print tb.Name
        End If
    Next tb
    Set db = Nothing
End Sub

Public Sub TestODBCLinks()
    RefreshODBCLinks
End Sub

Initial URL
http://stackoverflow.com/questions/564265/how-to-refresh-linked-tables-in-an-access-mdb-when-odbc-changes

Initial Description

                                

Initial Title
Refresh Access Linked Table

Initial Tags

                                

Initial Language
Visual Basic