设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

[与其它组件] 怎样用VB新建外部MDB文件.

[复制链接]
跳转到指定楼层
1#
发表于 2008-3-25 18:03:56 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
我做了一个程序,将当前的表的数据保存起来,用的是
      DoCmd.TransferDatabase acExport, "Microsoft Access", filename, acTable, "表名", "表名 "
这里的filenae 这个文件必须先存在,但当filename这个文件不存在时,怎样先新建这个文件呢.
查找外部文件命令是 dir filename
,但是新建外部文件呢,请指教。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
 楼主| 发表于 2008-3-25 18:39:16 | 显示全部楼层

找到答案了,用Workspace.CreateDatabase

If Dir(filename) = "" Then
        Dim wrkDefault As Workspace
        Dim dbsNew As Database
        Dim prpLoop As Property
          ' Get default Workspace.
        Set wrkDefault = DBEngine.Workspaces(0)
        ' Make sure there isn't already a file with the name of the new database.
        ' Create a new encrypted database with the specified collating order.
        Set dbsNew = wrkDefault.CreateDatabase(filename, dbLangGeneral, dbEncrypt)
             '    With dbsNew
          '  Debug.Print "; Properties of " & .name
            ' Enumerate the Properties collection of the new
                    ' Database object.
            ' For Each prpLoop In .Properties
            '    If prpLoop <> "" Then Debug.Print "  " & _
              '     prpLoop.name & " = " & prpLoop
            ' Next prpLoop
             ' End With
            dbsNew.close
       End If
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-15 04:35 , Processed in 0.105576 second(s), 25 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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