Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

How To Bundle Login Info to MS Access To Get to SQL Server Expand / Collapse
Author
Message
Posted Tuesday, January 21, 2014 8:45 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 8:44 AM
Points: 1, Visits: 3
In your LinkOneTable code you have:

TDf.Connect = S$
TDf.SourceTableName = Name$

Those variables aren't declared - S$ and Name$...


???
Post #1533154
Posted Wednesday, January 22, 2014 5:31 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: 2 days ago @ 6:24 AM
Points: 1,495, Visits: 2,632
You could use DSN-less connections. The first code will attach one table:
Sub AttachOne(TableName As String)
Const my_connection = "ODBC;DRIVER=SQL Native Client;SERVER=my_server;UID=my_username;PWD=my_password;DATABASE=my_database;"
'
Dim db As DAO.Database, tdf As DAO.TableDef
'
Set db = CurrentDb
Set tdf = db.CreateTableDef
With tdf
.Name = TableName
.SourceTableName = TableName
.Connect = my_connection
.Attributes = .Attributes Or dbAttachSavePWD
End With
db.TableDefs.Append tdf
End Sub

...and this code will refresh all of the linked tables:
Sub RelinkAll()
Const my_connection = "ODBC;DRIVER=SQL Native Client;SERVER=my_server;UID=my_username;PWD=my_password;DATABASE=my_database;"
'
Dim db As DAO.Database, tdf As DAO.TableDef
'
Set db = CurrentDb
For Each tdf In db.TableDefs
If tdf.Connect > "" Then
tdf.Connect = my_connection
tdf.RefreshLink
End If
Next tdf
End Sub

Post #1533576
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse