"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:\JollyServic e_2004\JollySer vice_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_Trasport i"
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.CreateTableD ef(LocalTableNa me(i))
'Set LinkedTable = db.CreateTableD ef(TableArray(i ))
LinkedTable.Con nect = ";DATABASE= " & TFileName
LinkedTable.Sou rceTableName = TableArray(i)
db.TableDefs.Ap pend LinkedTable
Next i
db.TableDefs.Re fresh
DoCmd.Hourglass False
End Sub
---------------------------------------------------------------
Bruno