S
Scott
I'm trying to "refresh" or "change" the database path of all linked tables
in my access file that are linked to "myFileA.mdb" so the tables become
linked to "myFileB.mdb". This code came from the Office 2000 Developer
CD-ROM and can be viewed the MSDN page
http://msdn.microsoft.com/library/d...n-us/odeopg/html/deovrcreatinglinkedtable.asp.
When I try to run the sub in the Immediate Window as shown below in the
IMMEDIATE WINDOW listing, I get an error saying
Compile Error: User-defined type not defined
What am I doing wrong? Can someone test this code and explain the error?
*** IMMEDIATE WINDOW **********
call RefreshLinks ("C:\data\databases\myFileA.mdb",
"c:\temp\myFileB.mdb")
*** CODE ***************
Sub RefreshLinks(strDBLinkFrom As String, _
strDBLinkSource As String)
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
Set catDB = New ADOX.Catalog
' Open a Catalog object on the database in which to refresh links.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDBLinkFrom
For Each tblLink In catDB.Tables
' Check to make sure table is a linked table.
If tblLink.Type = "LINK" Then
tblLink.Properties("Jet OLEDB:Link Datasource") =
strDBLinkSource
End If
Next
Set catDB = Nothing
End Sub
in my access file that are linked to "myFileA.mdb" so the tables become
linked to "myFileB.mdb". This code came from the Office 2000 Developer
CD-ROM and can be viewed the MSDN page
http://msdn.microsoft.com/library/d...n-us/odeopg/html/deovrcreatinglinkedtable.asp.
When I try to run the sub in the Immediate Window as shown below in the
IMMEDIATE WINDOW listing, I get an error saying
Compile Error: User-defined type not defined
What am I doing wrong? Can someone test this code and explain the error?
*** IMMEDIATE WINDOW **********
call RefreshLinks ("C:\data\databases\myFileA.mdb",
"c:\temp\myFileB.mdb")
*** CODE ***************
Sub RefreshLinks(strDBLinkFrom As String, _
strDBLinkSource As String)
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
Set catDB = New ADOX.Catalog
' Open a Catalog object on the database in which to refresh links.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDBLinkFrom
For Each tblLink In catDB.Tables
' Check to make sure table is a linked table.
If tblLink.Type = "LINK" Then
tblLink.Properties("Jet OLEDB:Link Datasource") =
strDBLinkSource
End If
Next
Set catDB = Nothing
End Sub