-
I have been having probs linking a table from one database to another. I am aiming to link the table "Traffic" from the source.mdb to the dest.mdb. I am getting a RTE 3125 when i run the code. The rte refers to "The database engine can't find ". Make sure it is a valid parameter or alias name, that it doesn't include invalid characters or punctuation etc etc
The RTE is pointing to the last line of code
Any ideas, i am stuck!!!!
Here is the code
Sub Main()
Dim dbsSource As Database
Dim dbsDest As Database
Dim daotdflink As TableDef
Dim sLinkHeader As String
sLinkHeader = ";DATABASE="
Set dbsDest = OpenDatabase("C:\windows\desktop\dest.mdb")
MsgBox ("hello")
Set daotdflink = dbsDest.CreateTableDef(traffic)
daotdflink.Connect = sLinkHeader & "C:\windows\desktop\source.mdb"
daotdflink.SourceTableName = traffic
dbsDest.TableDefs.Append daotdflink
End Sub
-
this code works fine for me:
Code:
Dim dbsSource As Database
Dim dbsDest As Database
Dim daotdflink As TableDef
Dim sLinkHeader As String
sLinkHeader = ";DATABASE="
Set dbsDest = OpenDatabase("nwindnew.mdb")
Set daotdflink = dbsDest.CreateTableDef("customers")
daotdflink.Connect = sLinkHeader & "nwind.mdb"
daotdflink.SourceTableName = "customers"
dbsDest.TableDefs.Append daotdflink
I think you just need to enclose TRAFFIC in quotes:
Code:
Dim dbsSource As Database
Dim dbsDest As Database
Dim daotdflink As TableDef
Dim sLinkHeader As String
sLinkHeader = ";DATABASE="
Set dbsDest = OpenDatabase("C:\windows\desktop\dest.mdb")
MsgBox ("hello")
Set daotdflink = dbsDest.CreateTableDef("traffic")
daotdflink.Connect = sLinkHeader & "C:\windows\desktop\source.mdb"
daotdflink.SourceTableName = "traffic"
dbsDest.TableDefs.Append daotdflink
Tom
-
Its almost There
Its almost there, but i now get an RTE referring to object "Traffic already exists". This is because i have a traffic table in my destination database. My aim is to make a linked table that i can use to move data around. I
Is there any way of naming the linked table something like
LINK_traffic etc. I need to have two databases with the same table names, so i will have to name the linked table differently.
If i remove the table traffic from the destination database then the link works.
Any ideas of how to name the link table differently.
M
-
I don't know why you'd want a linked table called TRAFFIC and a local table called TRAFFIC in the same db....
but you could just change this line:
Set daotdflink = dbsDest.CreateTableDef("traffic")
and call it whatever you want
example:
Set daotdflink = dbsDest.CreateTableDef("LNK_traffic")