VB ACCESS数据库关不掉
代码:Dim New_mdb As Object '定义对象
Private Sub Command1_Click()
'New_mdb.Application.Quit acQuitSaveAll
'WScr.application.quit acquitsaveall
New_mdb.Close
End Sub
Private Sub Form_Load()
Dim acc As String
Dim strpath As String
Dim mypassword As String
Dim Mmdb As String
Dim Fform As String
Dim WScr As Object
On Error Resume Next
acc = "Database3" '数据库名
Mmdb = ".accdb" '数据库类型
Fform = "窗体1" '登陆窗体名
strpath = App.Path & "\" & acc & Mmdb '数据库路径
Set New_mdb = CreateObject("access.application")
Set WScr = CreateObject("WScript.Shell")
''''启用所有宏
WScr.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\" & New_mdb.Version & "\Access\Security\VBAWarnings", _
"00000001", "REG_DWORD"
New_mdb.OpenCurrentDatabase strpath, False, mypassword '在新文件中打开数据库文件
New_mdb.UserControl = True '用户激活新打开的文件
New_mdb.DoCmd.OpenForm Fform ' '打开数据库的窗体,注意access不可以设置启动窗体
Set WScr = Nothing
Set New_mdb = Nothing
End Sub
我现在可以用VB打开ACCESS数据库,可是无法关掉。
提示:
请指教,谢谢!