Dim SrcDB As String, SrcTable As String
'SrcDB is used as a variable for the database in which 'the linked table resides. 'SrcTable is the name of the table you wish to link. 'The table will keep that name in this database. Sub LinkATable(SrcDB As String, SrcTable As String) Dim myDB As Database Set myDB = CurrentDb DoCmd.TransferDatabase acLink, "Microsoft Access", _ Left(myDB.Name, Len(myDB.Name) - Len("Destination.mdb")) & SrcDB, _ acTable, SrcTable, SrcTable, False End Sub Assumes: Replace Destination.mdb with the name of the database in which this code resides. |