Results 1 to 2 of 2
  1. #1
    jimbernie is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2012
    Posts
    1

    Link Tables with VBA from a menu selection

    Need help ......... going round in circles and getting dizzy ..



    I have an Access System, use a single folder that holds three databases, all exactly the same tables and structure except for data. One is a working database, one is a test database and the third is a training database. My data is held separate to my code obviously.

    I come in through a basic menu where I select which database I want, then set up the database name via a common module (public parameter) which worked fine in my test using a single database already linked into my code .mdb.

    Next step was to de-link the files when I exit from my system and that works well.

    Now comes to linking in the required tables from the selected database when I start up.

    All three databases are in a folder - c:\mysystem\datasystem.mdb, c:\mysystem\datatest.mdb and c:\mysystem\datatrain.mdb.

    I require to link in all the tables in the selected database and have scoured forums, etc but am having no luck, probably through a level of ignorance in getting it working from various examples. Just need a simple solution to link back in.

    My code for deleting when I exit is as follows and works perfect but I now need the reverse of it.

    Dim tdf As DAO.TableDef

    For Each tdf In CurrentDb.TableDefs
    ' If the table has a connect string, it's a linked table.
    If Len(tdf.Connect) > 0 Then
    DoCmd.DeleteObject acTable, tdf.Name
    End If
    Next tdf

    Can anyone help please, many thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Google: access vba set table links
    Does this help?
    http://www.eraserve.com/tutorials/MS...ink_Tables.asp

    Instead of deleting the links you could just modify. Review:
    http://forums.aspfree.com/microsoft-...ue-323364.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-29-2012, 10:53 PM
  2. link tables using vba
    By dumbledown in forum Import/Export Data
    Replies: 3
    Last Post: 03-09-2012, 05:27 AM
  3. Replies: 5
    Last Post: 08-11-2010, 09:16 AM
  4. One-way link between tables
    By Mikele di Sagitter in forum Database Design
    Replies: 1
    Last Post: 07-23-2010, 08:26 AM
  5. Best way to link tables together?
    By marleyuk in forum Access
    Replies: 1
    Last Post: 06-07-2009, 08:44 AM

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