Howdy, I'm self taught here so if I'm asking a dumb question I apologize. I've created an Access FE with a MSSQL BE. I don't want to have to create an ODBC connection for all the users (lazy I guess) so I found some code on the web that will allow me to not have to have odbc linked tables, modified it a bit and it seems to work fine. I created a table containing all the names of the tables I have in MSSQL, loop through those and create/refresh the tables. Please advise if I should pursue other measures.
Thanks
Public Sub CreateLinkedTable()
'Used to hold tabledef object and connection string
Dim td As TableDef
Dim ConnString As String
Dim LocalTableName As String
Dim SourceTableName As String
Dim SourceServerName As String
Dim SourceDatabaseName As String
Dim Login As String
Dim SourcePassword As String
Dim rs As DAO.Recordset
Dim db As Database
Set db = CurrentDb
strSQL = "SELECT [TableName] FROM tblnetworktables;"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
Do Until rs.EOF
'Sets all variable values for connection string
LocalTableName = rs(0).value
SourceTableName = rs(0).value
SourceServerName = "xxxxxxxxx"
SourceDatabaseName = "xxx"
Login = "xxxxxxxxx"
SourcePassword = "xxxxxxxxxxx"
'Creates connection string for the linked table
ConnString = "ODBC;DRIVER=SQL Server;SERVER=" & SourceServerName & ";DATABASE=" & SourceDatabaseName & ";UID=" & Login & ";PWD=" & SourcePassword
'Sets the table definition object
Set td = CurrentDb.CreateTableDef(LocalTableName, dbAttachSavePWD, SourceTableName, ConnString)
'Creates/refreshes the table by appending to the current list of table definitions.
On Error Resume Next
CurrentDb.TableDefs.Append td
CurrentDb.TableDefs.Refresh
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub

Thanks
Public Sub CreateLinkedTable()
'Used to hold tabledef object and connection string
Dim td As TableDef
Dim ConnString As String
Dim LocalTableName As String
Dim SourceTableName As String
Dim SourceServerName As String
Dim SourceDatabaseName As String
Dim Login As String
Dim SourcePassword As String
Dim rs As DAO.Recordset
Dim db As Database
Set db = CurrentDb
strSQL = "SELECT [TableName] FROM tblnetworktables;"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
Do Until rs.EOF
'Sets all variable values for connection string
LocalTableName = rs(0).value
SourceTableName = rs(0).value
SourceServerName = "xxxxxxxxx"
SourceDatabaseName = "xxx"
Login = "xxxxxxxxx"
SourcePassword = "xxxxxxxxxxx"
'Creates connection string for the linked table
ConnString = "ODBC;DRIVER=SQL Server;SERVER=" & SourceServerName & ";DATABASE=" & SourceDatabaseName & ";UID=" & Login & ";PWD=" & SourcePassword
'Sets the table definition object
Set td = CurrentDb.CreateTableDef(LocalTableName, dbAttachSavePWD, SourceTableName, ConnString)
'Creates/refreshes the table by appending to the current list of table definitions.
On Error Resume Next
CurrentDb.TableDefs.Append td
CurrentDb.TableDefs.Refresh
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub