How do I “chain” linked tables in Access?

前端 未结 3 1352
滥情空心
滥情空心 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: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=;Database=;UID=;PWD=
    

    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
    

提交回复
热议问题