Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
linked table via VBA alone
William Gibbs 
    
3 years ago
Is it possible to create a linked table via VBA without using the access prompts to do it?

Issue:

The Oracle tables im connecting with are now using larger table names than what was allowed in the past ( I believe this is the cause of the issue) and when it goes to pull the table list it breaks and gives me a error about truncated table names.

So I am trying to link the table directly with vba and I havent been able to work out how to do it yet. Any advice on how to proceed?
Dan Jackson  @Reply  
            
3 years ago
I asked ChatGPT, this is the response. Until someone on here can provide a "cleaner" answer, this might get you going

========================================

Yes, it is possible to create a linked table via VBA without using the Access prompts. You can use the "TableDef" object in VBA to create a linked table. Here is an example code that demonstrates how to create a linked table via VBA:

Dim db As DAO.Database
Dim tdf As DAO.TableDef

Set db = CurrentDb
Set tdf = db.CreateTableDef("LinkedTable")

tdf.Connect = "ODBC;Driver={SQL Server};Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes;"
tdf.SourceTableName = "dbo.MyTable"

db.TableDefs.Append tdf


In this example, a new TableDef object is created with the name "LinkedTable". The Connect property is set to the connection string for the external database, and the SourceTableName property is set to the name of the table in the external database that you want to link to. Finally, the TableDef object is appended to the TableDefs collection of the current database.

You will need to modify the connection string and table name to match your specific requirements.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 10:29:50 AM. PLT: 1s