Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to link db's in Access 2007

Status
Not open for further replies.

Greyfleck

IS-IT--Management
Jun 2, 2008
61
GB
I have two dbs, BRX and BRX_data which contains the tables.
I have a start up module that runs the following code.
I have managed to get the code to work but have had to hard code the "BRX_Data" bit & the "Msys" bit (to avoid Access tables).
Any clues as to how I can do this without the hard coding would be a help.
Both accdb's reside in the same folder.

As an additional question, do I have to de-link the tables and, if so, how?
Thanks

Jon
Code:
'***********************************************************
Function Link_to_tables()
Dim db As Database
Dim i As Integer
Dim dbsource As Variant
    datapath = CurrentProject.path + "\brx_data.accdb"
    Set db = OpenDatabase(datapath)
    
    db.TableDefs.Refresh
    
    For i = 0 To db.TableDefs.Count - 1
        If Left(db.TableDefs(i).Name, 4) <> "Msys" Then
            dbsource = db.TableDefs(i).Name
            DoCmd.TransferDatabase acLink, "Microsoft Access", datapath, acTable, dbsource, dbsource
        End If
    Next i
    Set db = Nothing

End Function
'*******************************
 

To simply link tables in Access 2007:

Click External Data, then Access Icon, then Select the "Link to Data..." radio button, Browse out to your "brx_data.accdb" file and click OK, you will then select the tables desired.

No need to "unlink" them ever.

No need to run any of the code you have created.

Sorry if I have mis-understood what you are asking.

Hope this helps.

Thanks,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top