会员登录 - 用户注册 - 网站地图 Office中国(office-cn.net),专业Office论坛
当前位置:主页 > 技巧 > Access技巧 > 数据库系统 > 正文

四种用代码打开外部Access(MDB)的方法

时间:2013-11-27 17:04 来源:office中国 作者:andymark 阅读:

方法1:
   Dim AccessPath As String
   Dim DbPath As String
   AccessPath = SysCmd(acSysCmdAccessDir) &"MSACCESS.EXE"
   DbPath = "C:\db1.mdb"
   Shell AccessPath &" " & DbPath


方法2:
    Dim DbPath As String

    DbPath = "C:\db1.mdb"
    Application.FollowHyperlink DbPath

 

方法3
  Private Declare Function ShellExecute Lib "shell32.dll" _
               Alias "ShellExecuteA" _
               (ByVal hwnd As Long, _
               ByVal lpOperation As String, _
               ByVal lpFile As String, _
               ByVal lpParameters As String, _
               ByVal lpDirectory As String, _
               ByVal nShowCmd As Long) As Long

   Sub OpenBd()
      Dim DbPath As String

      DbPath = "C:\db1.mdb"
   ShellExecute 0&, vbNullString, DbPath, vbNullString, vbNullString, 0&;

 End Sub

 

方法4:
    Dim DbPath As String
    Dim oApp As Access.Application

    DbPath = "c:\db1.mdb"
      Set oApp = New Access.Application
         With oApp
            .Visible = True
            .OpenCurrentDatabase DbPath
            .DoCmd.OpenForm "MyForm"
            .DoCmd.OpenReport "MyReport", acViewPreview
            .Run "MyFuncion"
         End With
    Set oApp = Nothing

 

(责任编辑:admin)

顶一下
(7)
100%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价: