■ Access VBA 実行コード
Option Compare Database
Option Explicit
Public Function ExGetParentPath(sPath As String) As String
Dim str As String
Dim n1 As Integer
Dim n2 As Integer
n2 = 0
Do
n2 = n2 + 1
n1 = InStr(n2, sPath, "\")
If n1 <> 0 Then n2 = n1
Loop While n1 <> 0
ExGetParentPath = Left(sPath, n2 - 1)
End Function
Private Sub コマンド0_Click()
'Accessのデータベース名から取り出す
Debug.Print ExGetParentPath(Application.CurrentDb.Name)
'Accessのデータベースがあるフォルダ名から取り出す
Debug.Print ExGetParentPath(Application.CurrentProject.Path)
End Sub