Good day!
I have a back-end database which is protected with password.
the following code imports one table only, I need a code to: 1) Link all tables in the back-end database; 2) Link particular tables.
Code:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strConnect As String
Dim strDbFile As String
Dim strLinkName As String
Dim strPassword As String
Dim strSourceTableName As String
Dim tdfBE As DAO.TableDef
Dim tdfFE As DAO.TableDef
strDbFile = "D:\myfile.accdb"
strPassword = "abc"
strSourceTableName = "client_master"
strLinkName = strSourceTableName
strConnect = "MS Access;PWD=" & strPassword & ";DATABASE=" & strDbFile
Debug.Print strConnect
Set db = CurrentDb
Set tdf = db.CreateTableDef
tdf.Connect = strConnect
tdf.SourceTableName = "xyz"
tdf.Name = strLinkName
db.TableDefs.Append tdf
I have a back-end database which is protected with password.
the following code imports one table only, I need a code to: 1) Link all tables in the back-end database; 2) Link particular tables.
Code:
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strConnect As String
Dim strDbFile As String
Dim strLinkName As String
Dim strPassword As String
Dim strSourceTableName As String
Dim tdfBE As DAO.TableDef
Dim tdfFE As DAO.TableDef
strDbFile = "D:\myfile.accdb"
strPassword = "abc"
strSourceTableName = "client_master"
strLinkName = strSourceTableName
strConnect = "MS Access;PWD=" & strPassword & ";DATABASE=" & strDbFile
Debug.Print strConnect
Set db = CurrentDb
Set tdf = db.CreateTableDef
tdf.Connect = strConnect
tdf.SourceTableName = "xyz"
tdf.Name = strLinkName
db.TableDefs.Append tdf