Refresh Access Linked Table


/ Published in: Visual Basic
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Option Compare Database
  2.  
  3. Public Sub RefreshODBCLinks(Optional newConnectionString As String)
  4. Dim db As DAO.Database
  5. Dim tb As DAO.TableDef
  6. Set db = CurrentDb
  7. Debug.Print "Refreshed ODBC table: "
  8. For Each tb In db.TableDefs
  9.  
  10. If Left(tb.Connect, 4) = "ODBC" Then
  11. If Len(Trim(newConnectionString)) > 0 Then
  12. tb.Connect = newConnectionString
  13. End If
  14. tb.RefreshLink
  15. Debug.Print tb.Name
  16. End If
  17. Next tb
  18. Set db = Nothing
  19. End Sub
  20.  
  21. Public Sub TestODBCLinks()
  22. RefreshODBCLinks
  23. End Sub

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.