Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linked Tables using ADO in Access XP

Status
Not open for further replies.

hd3

Programmer
Jul 15, 2003
2
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top