Link to home
Start Free TrialLog in
Avatar of CaroleTSullivan
CaroleTSullivan

asked on

Use VBA to link tables in SQL Server

I have an MSAccess database that links tables to a SQL Server database via ODBC.  I would like to dynamically link those tables when the database is opened to avoid having the user needing the ODBC entry on their PC.  I can establish the link to the SQL Server database but from there, how do I LINK the tables.

This is how I establish the connection to the sql server database.  Can I use VBA code to link to the tables I need from here?
        strsql = "Driver={SQL server}; Server=" & g_dbserver & "; Port=1433; Option=0; Socket=; Stmt=; Database=" & g_db & "; Uid=" & g_dbuserid & "; Pwd=" & g_dbpassword & "; Network=DBMSSOCN;"
        OBJdbConnection.Open strsql
        objCommand.ActiveConnection = OBJdbConnection
        OBJdbConnection.CommandTimeout = 0
        objCommand.CommandTimeout = 0
ASKER CERTIFIED SOLUTION
Avatar of Leigh Purvis
Leigh Purvis
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial