I wrote the following codes to linked a table from another Access database.
Dim db as DAO.Database
Dim TD as TableDef
Set db = CurrentDb
Set TD = db.CreateTableDef("TableNameAfterLink"
TD.Connect = ";Database=" & "G:\folder\target.mdb" 'Path to target database
TD.SourceTableName = "TableNameInExternalDatabase"
db.TableDefs.Append TD
Set TD = Nothing
db.close
And use the following codes to remove the linked table reference afterward:
Set db = CurrentDB
Set TD = db.TableDef("NameOfLinkedTable"
db.TableDefs.Delete "NameOfLinkedTable"
Set TD = Nothing
db.close
I works great. Now, how can I modify the code to link to a password protected database? Thanks!
Dim db as DAO.Database
Dim TD as TableDef
Set db = CurrentDb
Set TD = db.CreateTableDef("TableNameAfterLink"
TD.Connect = ";Database=" & "G:\folder\target.mdb" 'Path to target database
TD.SourceTableName = "TableNameInExternalDatabase"
db.TableDefs.Append TD
Set TD = Nothing
db.close
And use the following codes to remove the linked table reference afterward:
Set db = CurrentDB
Set TD = db.TableDef("NameOfLinkedTable"
db.TableDefs.Delete "NameOfLinkedTable"
Set TD = Nothing
db.close
I works great. Now, how can I modify the code to link to a password protected database? Thanks!