[FONT="Verdana"][SIZE="1"]Function CreateLinked(dbsDestination As DAO.Database, TableName As String, MDBSourcePath As String, Optional Password As String) As Boolean
[COLOR="Green"]' creates a link to TableName in database MDBSourcePath[/COLOR]
On Error GoTo handler
Dim tdf As DAO.TableDef
[COLOR="Green"] 'create the new tabledef object[/COLOR]
Set tdf = dbsDestination.CreateTableDef(TableName)
[COLOR="Green"] 'connect to the .mdb file on disk[/COLOR]
tdf.Connect = "MS Access;PWD=" & Password & ";DATABASE=" & MDBSourcePath
[COLOR="Green"] 'specify the table name in the .mdb[/COLOR]
tdf.SourceTableName = TableName
[COLOR="Green"] 'append the table[/COLOR]
dbsDestination.TableDefs.Append tdf
[COLOR="Green"] 'assign to function[/COLOR]
CreateLinked = True
final:
Exit Function
handler:
err.Raise err, err.Source & " in CreateTableLink()"
Resume final
End Function[/SIZE][/FONT]