Rx_
Nothing In Moderation
- Local time
- Today, 10:15
- Joined
- Oct 22, 2009
- Messages
- 2,803
Correction DSNLess: Finally got the code to work for SQL Security. Please note: I accidently posted this over a 2 year old post of mine when I did this for Access 2003. For what it is worth, my Access 2003 code did not work on Access 2010 with the same SQL Native 10 driver.
This code was very difficult to find. Looks so easy now. It was late evening, I think the brackets around the SQL Server Native Client 10.0 made a difference.
Also, the text for the dbo.<tablename> in the SQL Server Link is addressed here.
This works if an Access 2010 Linked table has an exact Table that was migrated to SQL Server 2008.
The Access Table Object icon stays an Access icon until several minutes later. Then it turns into the SQL Server Globe (green) icon.
Does anyone have an idea how to get the table icons to refresh quicker? It can be a minute or ten minutes for the table object icon to change.
While the Table object icon is still displaying the MSAccess icon format, hovering over the table icon shows "dbo.Const_Seed in" - they all have the table name followed by " in"
Once the table object icon converts to a SQL Server Globe icon - hovering over it has the full connection string.
Code calls my SQL_linked table - gets a Table Name then loops through a statement like this one.
This code was very difficult to find. Looks so easy now. It was late evening, I think the brackets around the SQL Server Native Client 10.0 made a difference.
Also, the text for the dbo.<tablename> in the SQL Server Link is addressed here.
This works if an Access 2010 Linked table has an exact Table that was migrated to SQL Server 2008.
The Access Table Object icon stays an Access icon until several minutes later. Then it turns into the SQL Server Globe (green) icon.
Does anyone have an idea how to get the table icons to refresh quicker? It can be a minute or ten minutes for the table object icon to change.
While the Table object icon is still displaying the MSAccess icon format, hovering over the table icon shows "dbo.Const_Seed in" - they all have the table name followed by " in"
Once the table object icon converts to a SQL Server Globe icon - hovering over it has the full connection string.
Code calls my SQL_linked table - gets a Table Name then loops through a statement like this one.
Code:
Sub RefreshDSNLess2() ' Existing table in Access 2010 was upsized to SQL Server 2008 RC2
Dim ConnectString As String
Dim strConnectionString As String
Dim scn As String
Dim sLocalName As String
Dim UID As String
Dim PWD As String
UID = "dataUser"
PWD = "dataPW"
sLocalName = "R_33" ' <<<---pick linked table with SQL Server Security
Dim DataBaseName As String
DataBaseName = "RegulatoryDB"
' Note - updated recently updated to SQL Server Native Client 11.0 ' really nice!
strConnectionString = "ODBC;DRIVER=SQL Server Native Client 10.0;" & _
"SERVER=DenReg-Test;DATABASE=" & DataBaseName & ";" & _
"UID=" & UID & ";" & _
"Password=" & PWD & ";" & _
"Table=DBO." & sLocalName ' & ";Option=3;" ' Don't actually know what option 3 does - think it peresists
Debug.Print strConnectionString
With CurrentDb
.TableDefs(sLocalName).Connect = strConnectionString 'scn
' ODBC;DRIVER=SQL Server Native Client 10.0;SERVER=DenReg-Test;DATABASE=RegulatoryDB;UID=datamig;Password=datamig;Table=DBO.R_33
.TableDefs(sLocalName).RefreshLink ' otherwise, it won't show until the user interface selects some other object, then returns back to Tables
End With
End Sub
Attachments
Last edited: