Results 1 to 4 of 4
  1. #1
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    313

    Changing a Table Link Dynamically

    I have several users who pick a text file for input into my Access database. It could reside anywhere, local drive, shared drive, etc. I'm using an Office.FileDialog process to allow them to pick the desired file, so I have the full pathname at that point. In the past, I have used FileCopy to copy the file to the file I have statically linked a table to. However, I would prefer just changing the table link to point to the selected file.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    One way:

    DoCmd.DeleteObject acTable, "ExcelWages"

    DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, "ExcelWages", strPath, True

    Changing the names to yours.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    313
    Almost there... the files they are linking to are text files, not spreadsheets, with an extension of .mct. Example, MC123456.mct. Note that there are no field names in the text files. The field names and definitions are in the linked tables.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    TransferText might work then. Not sure about the field names. You can try using a TableDef object and changing the path, but that's untested.

    http://msdn.microsoft.com/en-us/libr.../ff193791.aspx
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 05-02-2013, 11:14 PM
  2. Replies: 1
    Last Post: 04-12-2013, 07:56 AM
  3. Replies: 1
    Last Post: 01-31-2013, 02:58 PM
  4. Replies: 4
    Last Post: 01-13-2013, 02:40 AM
  5. Replies: 2
    Last Post: 08-01-2011, 11:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums