Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Linked Table by VBA

Status
Not open for further replies.

bibigol

Programmer
Jan 9, 2011
6
0
0
IR
Hi,

Is any body knows,
Can we create a linked tabled in VBA by any command??

Your help would appreciated
 


check out TransferDatabase Macro Action in HELP

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Code:
Public Sub linkTable()
   ' Call the ConnectOutput procedure. The third argument
   ' will be used as the Connect string, and the fourth
   ' argument will be used as the SourceTableName.
   ConnectOutput CurrentDb, "LinkedTable", ";DATABASE=C:\Nwind.mdb", "Products"
End Sub

Sub ConnectOutput(dbsTemp As Database, _
   strTable As String, strConnect As String, _
   strSourceTable As String)
   Dim tdfLinked As TableDef
   ' Create a new TableDef, set its Connect and
   ' SourceTableName properties based on the passed
   ' arguments, and append it to the TableDefs collection.
   Set tdfLinked = dbsTemp.CreateTableDef(strTable)
   tdfLinked.Connect = strConnect
   tdfLinked.SourceTableName = strSourceTable
   dbsTemp.TableDefs.Append tdfLinked
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top