View Full Version : Linked ODBC tables


Barguast
11-12-2007, 08:11 AM
My problem is best explained by example;

In Access Database A, I have some linked ODBC tables (to an SQL Server database) and some local tables.

In Access Database B, I have a front end which links to all the tables in Access Database A.

The problem is, when I try to link the tables in B, I cannot see the ODBC tables linked in A. Is there any reason why not? 'Why not link Access Database B to the SQL Server tables directly?', you may ask. Well, there is an answer to that but it is quite difficult to explain. I assure you there is one. :p

WayneRyan
11-12-2007, 10:06 AM
Barguast,

As far as I know, Access will only let you link to a real "physical" table
in another database. Maybe they enforce that to avoid "circular" references:

LinkedTableA --> LinkedTableB --> LinkedTableC --> LinkedTableA

You could go through the Linked tables in DatabaseA and
copy those exact links to DatabaseB. That would be OK to do. Not that
difficult with the TableDefs connection.

hth,
Wayne

Barguast
11-20-2007, 02:08 AM
Sorry for the late reply, but I've only just had a chance to try this and... it isn't working!

How is the VBA I'm using:

Public Sub LinkLinkedTables()

LinkTable "(linked table name)", ";DATABASE=(database A).mdb"

End Sub

Public Sub LinkTable(tableName As String, connect As String)

Dim tdfLinked As TableDef
Set tdfLinked = CurrentDb.CreateTableDef(tableName)

tdfLinked.connect = connect
tdfLinked.SourceTableName = tableName
CurrentDb.TableDefs.Append tdfLinked

End Sub

This code (LinkLinkedTables) is run from Database B. It says that it cannot find the specified table.

It does work with the specified table is local (in Database A), but not when it is a linked table, so either I need to do this differently, or it won't work at all. Any idea which it is? :p

Thanks for your previous reply, btw, :)