我的按钮名为Command10,Access文档新建在当前目录下,代码如下
Private Sub Command10_Click()
Dim cat As ADOX.Catalog
Set cat = New ADOX.Catalog
'在当前目录下建立名为newdata的Access数据库
cat.Create ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\Access练习实例.mdb" + ";")
a = MsgBox("新建成功!文件建立在当前目录中!", 1, "成功")
Dim MSAccess As New Access.Application
MSAccess.OpenCurrentDatabase (App.Path & "\Access练习实例.mdb")
Set MSAccess = OpenDatabase(Access练习实例)
MSAccess.Visible = True
End Sub