How do I “chain” linked tables in Access?

前端 未结 3 1318
滥情空心
滥情空心 2021-01-05 10:28

My scenario: Computer A has an Access database that contains linked tables. Those linked tables actually reside in another Access database on Computer B. Nothing unusual y

相关标签:
3条回答
  • 2021-01-05 10:40

    Could you create a query/view on B that is just a view of the linked table on C, so that A can then access the query/view on B (which is actually the table on C)?

    like:

    
    Linked Query on A     ->     Query on B
                                    :
                           Linked table on B     ->    Real table on C
    
    

    edit after comment: OK, apparently you can't link to Queries, so that won't work then.

    One other idea: Can you set up Replication between B and C so that all of C's tables are replicated to B, where A can access them?

    0 讨论(0)
  • 2021-01-05 10:43

    In regard to the query suggestion, it's possible to use an IN 'C:\OtherDatabase.mdb' clause in a FROM clause:

    SELECT qryMyTable.*
    FROM qryMyTable IN 'c:\OtherDatabase.mdb';
    

    This will display for you in the database where the query is stored the contents of the query in the other database. If that path to the other database doesn't change, you could use this method to piggyback on that other database's linked tables.

    0 讨论(0)
  • 2021-01-05 10:50

    Nope - you can only link to real tables - you have to recreate the SQL server links you did on database B for database A

    If the SQL server data does not change much and you are just using it for lookups you could import the data into real Access tables which you could link to.

    EDIT

    Another solution is to link the tables dynamically - that way you don't have to add the DSN manually to each computer. Use a connection string something like this:

    ODBC;Driver={SQL Server};Server=<server name/IP>;Database=<database>;UID=<user>;PWD=<password>
    

    This links a table

    Dim db As Database
    Dim TD As TableDef
    Dim sTableName As String  ''MS Access name (can be same as SQL Server name)
    Dim sServerTableName As String  ''SQL Server Name 
    
    sTable = "Table1"
    sServerTableName  = "dbo.Table1"
    sServerConnect = "ODBC;Driver={SQL Server};Server=Localhost;Database=DB1;"
    
    Set TD = db.CreateTableDef(sTableName)
    TD.Connect = sServerConnect
    TD.SourceTableName = sServerTableName
    
    db.TableDefs.Append TD
    db.TableDefs.Refresh
    
    0 讨论(0)
提交回复
热议问题