Link to home
Start Free TrialLog in
Avatar of Chuck Wood
Chuck WoodFlag for United States of America

asked on

How To Create a Link to a SQL Server 2012 Table from Access 2010?

How do I manually create a link in Access 2010 to a SQL Server 2012 database table using the following connection String?

ODBC;
DRIVER=SQL Server;SERVER=MySqlServer;
Trusted_Connection=Yes;
APP=SSMA;
DATABASE=MyDb;
TABLE=GL_MyTable;
Avatar of Eric Sherman
Eric Sherman
Flag of United States of America image

Manually using VBA Code or do you mean manually using the Access database window???

ET
Avatar of Chuck Wood

ASKER

Yes.
Which one ... using code or from Access database window???

Et
Using the Access database window.
In VBA Code ... I use a 1 record table called SetupGeneral to store various parameters like SQL Login information.  Then use the DLookup function in code to get parameters when needed as shown below.

Dim strSQLServerHost As String 
Dim strSQLDatabase As String
Dim strSQLLogin As String
Dim strSQLPswd As String 
Dim strSQLConn As String

strSQLServerHost = DLookup("[SQL_SERVERHOST]", "SetupGeneral")
strSQLDatabase = DLookup("[SQL_DATABASE]", "SetupGeneral)
strSQLLogin = DLookup("[SQL_LOGIN]", "SetupGeneral)
strSQLPswd = DLookup("[SQL_PSWD]", "SetupGeneral)


'Build the SQL Server Connection String
strSQLConn = "ODBC;Driver={SQL Server};Server=" & strSQLServerHost & ";Database=" & strSQLDatabase & ";Uid=" & strSQLLogin & ";Pwd=" & strSQLPswd & ";"

Open in new window


ET
ASKER CERTIFIED SOLUTION
Avatar of Eric Sherman
Eric Sherman
Flag of United States of America 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
That worked. Thank you.