设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1579|回复: 3
打印 上一主题 下一主题

[其它] 用vba代码创建数据库,发生错误,请高手来改!谢谢!

[复制链接]
跳转到指定楼层
1#
发表于 2004-2-10 22:28:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
appAccess.Application.Visible = True
appAccess.SaveAs "C:\TEST.mdb"   ‘系统提示对象错误!请改!
appAccess.Application.Quit
Set appAccess = Nothing
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
 楼主| 发表于 2004-2-10 22:58:00 | 只看该作者
嘿嘿,搞定了,不用了谢谢!
用代码创建个新的数据库:
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
3#
发表于 2004-2-11 17:53:00 | 只看该作者
Dim appAccess As New Access.Application
appAccess.NewCurrentDatabase "C:\test"
appAccess.Quit
set appAccess=Nothing

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

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

请教!如何创建带密码的数据库?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-20 22:53 , Processed in 0.096605 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表