给你个通用的函数:DBPath = ValidateDir(App.Path) & DBName ' 判断目录是否合法,视情况加上斜杠“\” Function ValidateDir(ByVal tmpPath As String) As String If tmpPath = "" Then Exit Function If Right(tmpPath, 1) = "\" Then ValidateDir = tmpPath Else If tmpPath <> "" Then ValidateDir = tmpPath & "\" Else ValidateDir = "" End If End If End Function
Data1.DatabaseName = App.Path & "your.mdb"
' 判断目录是否合法,视情况加上斜杠“\”
Function ValidateDir(ByVal tmpPath As String) As String
If tmpPath = "" Then Exit Function
If Right(tmpPath, 1) = "\" Then
ValidateDir = tmpPath
Else
If tmpPath <> "" Then
ValidateDir = tmpPath & "\"
Else
ValidateDir = ""
End If
End If
End Function