A
Alastair MacFarlane
Dear Group,
I am trying to create a linked table between two
databases. I have:
DatabaseA has TableA and DatabaseB has no tables.
I would like the sub to be run from DatabaseA that opens
DatabaseB and creates a link in DatabaseB to TableA in
DatabaseA.
The code works OK if I am in DatabaseB and I run the code
to create a link with TableA in DatabaseA, but I have
tried to turn it around:
Private Sub CreateLink()
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = DBengine.OpenDatabase("DatabaseA")
Set tdf = dbs.CreateTableDef("TableA")
With tdf
.Connect = ";Database=C:\DatabaseA"
.SourceTableName = "TableA"
dbs.TableDefs.Append tdf
End With
Set dbs = Nothing
End Sub
Can anyone help with how I can do this? Thanks again…
Alastair MacFarlane
I am trying to create a linked table between two
databases. I have:
DatabaseA has TableA and DatabaseB has no tables.
I would like the sub to be run from DatabaseA that opens
DatabaseB and creates a link in DatabaseB to TableA in
DatabaseA.
The code works OK if I am in DatabaseB and I run the code
to create a link with TableA in DatabaseA, but I have
tried to turn it around:
Private Sub CreateLink()
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Set dbs = DBengine.OpenDatabase("DatabaseA")
Set tdf = dbs.CreateTableDef("TableA")
With tdf
.Connect = ";Database=C:\DatabaseA"
.SourceTableName = "TableA"
dbs.TableDefs.Append tdf
End With
Set dbs = Nothing
End Sub
Can anyone help with how I can do this? Thanks again…
Alastair MacFarlane