By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,378 Members | 3,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,378 IT Pros & Developers. It's quick & easy.

Link tables by code in Ms Access

P: 31
Iam using ms access and want to link to another access table name table1 using vb code.

kindly help me on getting code.

Ananth
Sep 12 '08 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,638
This is the simplest Method that I know for dynamically Linking a Table, just substitute your own values for the Constants (Lines 1 to 4). The following code will Link to the Employees Table in C:\Test\Northwind.mdb, the Name of this Table as displayed in your Database Window will be Employees_Local, and will consist of the data as well as the Structure of the Linked Table:
Expand|Select|Wrap|Line Numbers
  1. Const conEXTERNAL_DB_PATH  As String = "C:\Test\Northwind.mdb"
  2. Const conTABLE_TO_LINK As String = "Employees"
  3. Const conLOCAL_TABLE_NAME As String = "Employees_Local"
  4. Const conSTRUCTURE_ONLY As Boolean = False
  5.  
  6. DoCmd.TransferDatabase acLink, "Microsoft Access", conEXTERNAL_DB_PATH, _
  7.                        acTable, conTABLE_TO_LINK, _
  8.                        conLOCAL_TABLE_NAME, conSTRUCTURE_ONLY
  9.  
Sep 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.