can a create a linked table from one Access DB to another DB via VBScript? -


i can use vbscript. access database version 2013.

i have source ms access database table named "sourcetbl". right now, write vbscript such destination ms access database can create linked table of "sourcetbl".

i have tried google answer. seem not. can help? thank in advance.

the code have tried using dao open 2 databases , try use docmd.transferdatabase tabledefs.append. both properties seem not used in vbscript:

strdbpath = "c:\temp\sourcedb.accdb" set dbe = createobject("dao.dbengine.120") set wrkjet = dbe.createworkspace("", "admin", "", 2) ' dbusejet = 2 set db = wrkjet.opendatabase(strdbpath, true, false)  strdbpath2 = "c:\temp\destdb.accdb" set dbe2 = createobject("dao.dbengine.120") set wrkjet2 = dbe2.createworkspace("", "admin", "", 2) ' dbusejet = 2 set db2 = wrkjet2.opendatabase(strdbpath2, true, false)  'i tried use transferdatabase dbe2.docmd.transferdatabase aclink, "microsoft access", "c:\temp\sourcedb.accdb", actable, "sourcetbl", "sourcetbl"  'or use tabledefs, both not work db2.tabledefs.append db.tabledefs("sourcetbl")  db.close set db = nothing set wrkjet = nothing set dbe = nothing  db2.close set db2 = nothing set wrkjet2 = nothing set dbe2 = nothing 

** part 2 - tried use "createtabledef", however, error shown: "no field defined--cannot append tabledef or index"

strdbpath = "c:\temp\sourcedb.accdb" set dbe = createobject("dao.dbengine.120") set wrkjet = dbe.createworkspace("", "admin", "", 2) ' dbusejet = 2 set db = wrkjet.opendatabase(strdbpath, true, false)  strdbpath2 = "c:\temp\destdb.accdb" set dbe2 = createobject("dao.dbengine.120") set wrkjet2 = dbe2.createworkspace("", "admin", "", 2) ' dbusejet = 2 set db2 = wrkjet2.opendatabase(strdbpath2, true, false)  set tdf = db2.createtabledef("sourcetbl") tdf.connect = db.connect tdf.sourcetablename = "sourcetbl" db2.tabledefs.append tdf  db.close set db = nothing set wrkjet = nothing set dbe = nothing  db2.close set db2 = nothing set wrkjet2 = nothing set dbe2 = nothing 


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -