I am using the code below. It will actually create the linked table, but I am unable to programatically specify the unique record id for the tables. Without this I am unable to edit the table's data. Any help would be appreciated.
Thanks.
Function LinkToDSNLess()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strConnect As String
strConnect = "ODBC;DRIVER={SQL Server}" _
& ";SERVER=" & "MY_SERVER" _
& ";DATABASE=" & "MY_DATABASE" _
& ";UID=" & "my_user" _
& ";PWD=" & "mypassword" & ";"
Set db = CurrentDb()
Set tdf = db.CreateTableDef("dbo_Table1")
tdf.SourceTableName = "Table1"
tdf.Connect = strConnect
On Error Resume Next
db.TableDefs.Append tdf
db.TableDefs.Refresh
Set tdf = Nothing
Set db = Nothing
End Function
Thanks.
Function LinkToDSNLess()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strConnect As String
strConnect = "ODBC;DRIVER={SQL Server}" _
& ";SERVER=" & "MY_SERVER" _
& ";DATABASE=" & "MY_DATABASE" _
& ";UID=" & "my_user" _
& ";PWD=" & "mypassword" & ";"
Set db = CurrentDb()
Set tdf = db.CreateTableDef("dbo_Table1")
tdf.SourceTableName = "Table1"
tdf.Connect = strConnect
On Error Resume Next
db.TableDefs.Append tdf
db.TableDefs.Refresh
Set tdf = Nothing
Set db = Nothing
End Function