AutoLink databases

robins

New member
Local time
Today, 07:28
Joined
Dec 24, 2010
Messages
3
Hello. I've created 3 mdb files. One consist of forms, reports, queries and links to my tables. Other 2 files consists of tables. How should I relink them using VB when I move my data files somewhere in anothether folder?
 
I mean relinking when I start my application. It should test connection and if false show me the window to select new path to my 2 mdb files.
 
You can -

Check out this Access Relinker (free) from J Street Technology (Access MVP Armen Stein).
 
Wow!!!Super!!! Thanks a lot!!! Very fast answer. I couldn't find it for a long time. I've found the solution for one _be file, but not for many! Thank again!
 
The code first closes all open forms. This "releases" any links that the forms may have to the tables.
Next it removes the linked tables.
Lastly it relinks the tables.

Code:
[COLOR="SeaGreen"]'Close all open forms[/COLOR]
Dim frm As Object
    For Each frm In CurrentProject.AllForms
        If frm.IsLoaded Then
            DoCmd.Close acForm, frm.Name
        End If
Next frm

[COLOR="seagreen"]'Delete all current linked tables[/COLOR]

            DoCmd.DeleteObject acTable, "Table1"
            DoCmd.DeleteObject acTable, "Table2"

[COLOR="seagreen"]'Link tables[/COLOR]
      
    DoCmd.TransferDatabase acLink, "Microsoft Access", "c:\Data\BE1.mdb", acTable, "Table1", "Table1", False
    DoCmd.TransferDatabase acLink, "Microsoft Access", "c:\Data\BE2.mdb", acTable, "Table1", "Table2", False

Example has the data in c:\Data\
There are 2 tables that are linked as Table1 and Table2.
Both BE's have a table called Table1.
In the FE Table1 from BE1 is called Table1.
In the FE Table1 from BE2 is called Table2.
 

Users who are viewing this thread

Back
Top Bottom