带有OpenCurrentDatabase的运行时错误7866 [英] Run-Time Error 7866 with OpenCurrentDatabase
本文介绍了带有OpenCurrentDatabase的运行时错误7866的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行下面的代码时,出现运行时错误7866
:
When I run the code below I get Run-Time Error 7866
:
Microsoft Access无法打开数据库,因为它已丢失或由另一个用户独占打开,或者它不是ADP文件.
此行引发错误
db.OpenCurrentDatabase "C:\Users\QE9142\Desktop\VES Mgmt Reports ONLY.mdb"
我正在尝试打开通过Excel保存在桌面上的Access数据库.
I am trying to open an Access database that is saved on my desktop through Excel.
Sub Task()
Dim db As Access.Application
Dim strDB As String
Set db = New Access.Application
db.OpenCurrentDatabase "C:\Users\QE9142\Desktop\VES Mgmt Reports ONLY.mdb"
db.Application.Visible = True
End Sub
推荐答案
我无法复制此错误,但是当代码退出时,Access也是如此.
I can't replicate this error, but when the code exits, so does Access.
插入将保存代码的STOP或其他事件:
Insert a STOP or other event that will hold the code:
Sub Task()
Dim db As Access.Application
Dim strDB As String
Set db = New Access.Application
db.OpenCurrentDatabase "C:\Users\QE9142\Desktop\VES Mgmt Reports ONLY.mdb"
db.Application.Visible = True
Stop
End Sub
对于错误,请尝试在Access中打开mdb并将其另存为 accdb 文件(Access 2007格式).
As for the error, try opening the mdb in Access and save it as an accdb file (Access 2007 format).
这篇关于带有OpenCurrentDatabase的运行时错误7866的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文