會員登錄 - 用戶注冊 - 網(wǎng)站地圖 Office中國(office-cn.net),專業(yè)Office論壇

四種用代碼打開外部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%
發(fā)表評論
請自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴禁發(fā)布色情、暴力、反動的言論。
評價: