Office中国论坛/Access中国论坛

标题: 用vba代码创建数据库,发生错误,请高手来改!谢谢! [打印本页]

作者: 徐阿鹏    时间: 2004-2-10 22:28
标题: 用vba代码创建数据库,发生错误,请高手来改!谢谢!
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
appAccess.Application.Visible = True
appAccess.SaveAs "C:\TEST.mdb"   ‘系统提示对象错误!请改!
appAccess.Application.Quit
Set appAccess = Nothing
作者: 徐阿鹏    时间: 2004-2-10 22:58
嘿嘿,搞定了,不用了谢谢!
用代码创建个新的数据库:
Dim wrkDefault As Workspace
    Dim dbsNew As Database
     ' Get default Workspace.
   Set wrkDefault = DBEngine.Workspaces(0)

    ' Make sure there isn't already a file with the name of
    ' the new database.
    If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"

    ' Create a new encrypted database with the specified
    ' collating order.
    Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", _
        dbLangGeneral, dbEncrypt)

      dbsNew.Close
作者: 不是高手    时间: 2004-2-11 17:53
Dim appAccess As New Access.Application
appAccess.NewCurrentDatabase "C:\test"
appAccess.Quit
set appAccess=Nothing

[此贴子已经被作者于2004-2-11 10:25:02编辑过]


作者: sxgaobo    时间: 2019-10-2 09:07
徐阿鹏 发表于 2004-2-10 22:58
嘿嘿,搞定了,不用了谢谢!
用代码创建个新的数据库:
Dim wrkDefault As Workspace

请教!如何创建带密码的数据库?




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3