jar*_*mey 5 ms-access odbc access-vba linked-tables
我已经为我的问题引用了其他页面,但我仍然无法使其工作.鉴于我有三个例子,我觉得有点慢,但仍然无法解决这个问题.
这是我正在使用的代码:
Dim tdf As TableDef
Dim db As Database
Set db = CurrentDb
Set tdf = db.TableDefs("DeviceListT")
tdf.Connect = "ODBC;DATABASE=" & CurrentProject.path _
& "\HarmonicProfileDatabase_be.accdb"
tdf.RefreshLink
Run Code Online (Sandbox Code Playgroud)
问题是当我运行它时会弹出一个窗口.
我不确定我应该做什么,也不想让它首先弹出,因为我将ms访问文件提供给其他人,他们也不知道如何处理这个窗口.
您正在使用SQL Server引用但链接MS Access.对于MS Access,您不需要ODBC链接,只需参考DATABASE:
DBFile = CurrentProject.path & "\HarmonicProfileDatabase_be.accdb
''Check the file exists
strFile = Dir(DBFile)
If strFile <> "" Then
With CurrentDb
For Each tdf In .TableDefs
''Check that this is a linked table
''It can be useful to use table of tables instead
If tdf.Connect Like "*HarmonicProfileDatabase_be.accdb*" Then
tdf.Connect = ";DATABASE=" & DBFile
tdf.RefreshLink
End If
Next
End With
MsgBox "Link HarmonicProfileDatabase_be.accdb"
Else
MsgBox "Problem"
End If
Run Code Online (Sandbox Code Playgroud)
你也可以使用:
sConnect = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" _
& DBFile & ";Jet OLEDB:Database Password=pw;"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
14947 次 |
最近记录: |