Update an Access linked table to use a UNC path

后端 未结 3 1559
自闭症患者
自闭症患者 2020-12-06 18:40

I have an Access 2010 database A.mdb with a list of tables, one of which is a linked table, linked from another Access database B.mdb on th

相关标签:
3条回答
  • 2020-12-06 18:44

    you can right click a linked table and select Linked table Manager. Select the linked table you want to work on and tic the checkbox bellow the window which says Always prompt for new location and click the OK button.

    You will be asked for the new location. Browse and select the file and click OK.

    0 讨论(0)
  • 2020-12-06 18:57

    I like to set up a File DSN on a shared folder accessible with read-access to our entire network and then use a linked table manager to the UNC path. To do this, I use the linked table manager and set up a file DSN on my desktop. I then copy and move the DSN file to the shared UNC directory. Then, I go into Access and delete the linked Table and recreate the linked table. To do this, after deleting the linked table, I do the following:

    1. I click on ODBC Database-->Link to the data source by creating a linked table-->OK.
    2. Click the File Data Source Tab in the Select Data Source Window. At the bottom of the dialogue box, you will see "DSN Name:" followed by a text box and a New Button. You will enter the entire UNC path AND filename into that text box (so this is pointing to the file you copied out to the UNC path). For example, I enter, \ATD-SERVER1\AccessShare\ContactsApp.accdb.dsn. Then click OK.

    Assuming you have access permissions to server you are linking to, the Link Tables dialogue box will be displayed and you can then select your linked tables from there! Microsoft couldn't make this any less intuitive if they tried.

    0 讨论(0)
  • 2020-12-06 19:05

    Table links can be UNC paths. For example, say I have a linked table pointing to a database on \\192.168.1.2\Public\ which is mapped to drive P:. If I launch the VBA editor (Alt+F11), open the Immediate Window (Ctrl+G) and type...

    ?CurrentDB.TableDefs("remoteTable").Connect

    ...it will return...

    ;DATABASE=P:\B.accdb

    ...because I pointed to drive P: when I created the link.

    Now if I create and run the VBA function...

    Function linkToUnc()
    Dim cdb As DAO.Database
    Set cdb = CurrentDb
    cdb.TableDefs("remoteTable").Connect = ";DATABASE=\\192.168.1.2\Public\B.accdb"
    cdb.TableDefs("remoteTable").RefreshLink
    Set cdb = Nothing
    End Function
    

    ...the link is now a UNC path.

    By the way, you can create UNC links in the Linked Table Manager if you browse to "Network", "machine name", "share name", but that will give you the machine name (in my case \\PICO\Public\B.accdb).

    0 讨论(0)
提交回复
热议问题