Hello. I hope somebody can assist me.
I'm writing code to link to a table from Access XP to another database in Access XP. Both the 'linked from' and 'linked to' databases have user level security implemented.
Here is my code (that doesn't work...) I get a message saying invalid path...
Sub CreateLinkedAccessTable()
Dim strDBLinkFrom,strDBLinkTo As String
Dim strLinkTbl,strLinkTblAs As String
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
strDBLinkFrom = "Password=;User ID=DCAdmin;Data Source=P:\ScrapBaseXP.mdb;Jet OLEDB:System database=P:\ScrapBase.mdw"
strDBLinkTo = "Password=blahblah;User ID=DCAdmin;Data Source=P:\PRODBASE\ProdBase2002.mdb;Mode=Read;Jet OLEDB:System database=P:\PRODBASE\ProdBase97.mdw"
strLinkTbl = "Production Data"
strLinkTblAs = "LinkProd"
Set catDB = New ADOX.Catalog
' Open a Catalog on the database in which to create the link.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
strDBLinkFrom
Set tblLink = New ADOX.Table
With tblLink
' Name the new Table and set its ParentCatalog
' property to the
' open Catalog to allow access to the Properties
' collection.
.Name = strLinkTblAs
Set .ParentCatalog = catDB
' Set the properties to create the link.
.Properties("Jet OLEDB:Create Link" = True
.Properties("Jet OLEDB:Link Datasource" = strDBLinkTo
.Properties("Jet OLEDB:Remote Table Name" = strLinkTbl
End With
' Append the table to the Tables collection.
catDB.Tables.Append tblLink
Set catDB = Nothing
End Sub
I'm writing code to link to a table from Access XP to another database in Access XP. Both the 'linked from' and 'linked to' databases have user level security implemented.
Here is my code (that doesn't work...) I get a message saying invalid path...
Sub CreateLinkedAccessTable()
Dim strDBLinkFrom,strDBLinkTo As String
Dim strLinkTbl,strLinkTblAs As String
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
strDBLinkFrom = "Password=;User ID=DCAdmin;Data Source=P:\ScrapBaseXP.mdb;Jet OLEDB:System database=P:\ScrapBase.mdw"
strDBLinkTo = "Password=blahblah;User ID=DCAdmin;Data Source=P:\PRODBASE\ProdBase2002.mdb;Mode=Read;Jet OLEDB:System database=P:\PRODBASE\ProdBase97.mdw"
strLinkTbl = "Production Data"
strLinkTblAs = "LinkProd"
Set catDB = New ADOX.Catalog
' Open a Catalog on the database in which to create the link.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
strDBLinkFrom
Set tblLink = New ADOX.Table
With tblLink
' Name the new Table and set its ParentCatalog
' property to the
' open Catalog to allow access to the Properties
' collection.
.Name = strLinkTblAs
Set .ParentCatalog = catDB
' Set the properties to create the link.
.Properties("Jet OLEDB:Create Link" = True
.Properties("Jet OLEDB:Link Datasource" = strDBLinkTo
.Properties("Jet OLEDB:Remote Table Name" = strLinkTbl
End With
' Append the table to the Tables collection.
catDB.Tables.Append tblLink
Set catDB = Nothing
End Sub