"ABinBoston" <ab********@aol.com> wrote in message
news:20***************************@mb-m01.aol.com...
I was uaing some code derived from the Northwind database to relimk tables
at
startup.
The code works well in accerss 97/2000, but does not in 2003
Does anyone have any references to a Relinker in Access 2003?
Try this:
--------------------------------------------------
Private Sub Command0_Click()
Dim db As Database, n As Integer, i As Integer
Dim TFileName As String, LinkedTable As TableDef
Dim LocalTableName() As String, TableArray() As String
Set db = CurrentDb
' External database
TFileName = "C:\JollyService_2004\JollyService_T.mdb"
DoCmd.Hourglass True
n = 4
ReDim TableArray(1 To n)
' Tables existing on external database
TableArray(1) = "t_UM"
TableArray(2) = "t_IVA_Aliq"
TableArray(3) = "t_Trasporti"
TableArray(4) = "t_CT"
ReDim LocalTableName(1 To n)
' Names you want to assign to linked tables
LocalTableName(1) = "T1"
LocalTableName(2) = "T2"
LocalTableName(3) = "T3"
LocalTableName(4) = "T4"
' If you want to link external tables with their
' external names use the REMed Set LinkedTable
' instead of the other one.
For i = 1 To n
Set LinkedTable = db.CreateTableDef(LocalTableName(i))
'Set LinkedTable = db.CreateTableDef(TableArray(i))
LinkedTable.Connect = ";DATABASE=" & TFileName
LinkedTable.SourceTableName = TableArray(i)
db.TableDefs.Append LinkedTable
Next i
db.TableDefs.Refresh
DoCmd.Hourglass False
End Sub
---------------------------------------------------------------
Bruno