Access で SQL Server ヘリンクテーブルを貼る方法としていくつかありますが、簡単なのは 下記 VBA で行う方法かと思います。
■ Access でリンク テーブルのSQL Serverへの DSN レス接続を作成する方法
https://learn.microsoft.com/ja-jp/office/troubleshoot/access/create-dsn-less-connection-linkted-table
vba
1Sub Test()
2 Dim stLocalTableName As String
3 Dim stRemoteTableName As String
4 Dim stServer As String
5 Dim stDatabase As String
6 Dim stUsername As String
7 Dim stPassword As String
8
9 stLocalTableName = "dbo_テーブル名"
10 stRemoteTableName = "dbo.テーブル名"
11 stServer = "サーバー名"
12 stDatabase = "データベース名"
13 stUsername = "ユーザー名"
14 stPassword = "パスワード名"
15
16 AttachDSNLessTable stLocalTableName, stRemoteTableName, stServer, stDatabase, stUsername, stPassword
17End Sub
18
19Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As String, Optional stPassword As String)
20 On Error GoTo AttachDSNLessTable_Err
21 Dim td As TableDef
22 Dim stConnect As String
23
24 For Each td In CurrentDb.TableDefs
25 If td.Name = stLocalTableName Then
26 CurrentDb.TableDefs.Delete stLocalTableName
27 End If
28 Next
29
30 If Len(stUsername) = 0 Then
31 '//Use trusted authentication if stUsername is not supplied.
32 stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
33 Else
34 '//WARNING: This will save the username and the password with the linked table information.
35 stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & ";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
36 End If
37
38 Set td = CurrentDb.CreateTableDef(stLocalTableName, dbAttachSavePWD, stRemoteTableName, stConnect)
39 CurrentDb.TableDefs.Append td
40 AttachDSNLessTable = True
41
42 Exit Function
43
44AttachDSNLessTable_Err:
45 AttachDSNLessTable = False
46 MsgBox "AttachDSNLessTable encountered an unexpected error: " & Err.Description
47
48End Function
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。