|
经过几次测试
A数据库添加代码
Option Compare Database
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Const SW_SHOW = 1
Private Sub Form_Load()
ShellExecute 0, "Open", "c:\b.mdb", "", "", SW_SHOW '打开B数据库
Application.Quit 退出A.mdb
End Sub
B数据库代码差不多,不过事件上要调整一下.
Option Compare Database
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Const SW_SHOW = 1
Private Sub Form_Timer() '这里为时间触发器1毫秒
ShellExecute 0, "Open", "c:\a.mdb", "", "", SW_SHOW '打开A数据库
Application.Quit 退出该数据库
End Sub
经过多次实验这种方法没有出现问题
如果b数据库在加载事件中则会出现不正常现象,可能太快了还来不及执行 所以加了一个1毫秒进行事件触发就没问题了 |
|