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
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
'*******************************