Converting DAO to ADO
Posted
by webworm
on Stack Overflow
See other posts from Stack Overflow
or by webworm
Published on 2010-06-17T13:59:31Z
Indexed on
2010/06/17
14:23 UTC
Read the original article
Hit count: 319
I am working with an Access 2003 database that has a subroutine using DAO code. This code loops through the table definitions and refreshes the ODBC connection string. I would like to convert this to ADO so I do not have to reference the DAO object library. Here is the code ...
Public Sub RefreshODBCLinks(newConnectionString As String)
Dim db As DAO.Database
Dim tb As DAO.TableDef
Set db = CurrentDb
For Each tb In db.TableDefs
If Left(tb.Connect, 4) = "ODBC" Then
tb.Connect = newConnectionString
tb.RefreshLink
Debug.Print "Refreshed ODBC table " & tb.Name
End If
Next tb
Set db = Nothing
MsgBox "New connection string is " & newConnectionString, vbOKOnly, "ODBC Links refreshed"
End Sub
The part I am unsure of is how to loop through the tables and get/set their connection strings.
© Stack Overflow or respective owner