Robert Vivian said:
Directory containing the file is C:\Documents and Settings\default\My
Documents\My Projects. Diectory returned by CurDir is C:\Documents and
Settings\default\My Documents. I would have expected My Projects to be
included in the path returned by CurDir but it is not so merging with the
filename accomplishes nothing. I do not understand why CurDir does not
include the current directory in the returned path.
I'm not sure because usually i use DAO Library, you are using ADO now
but i think you have also CurrentProject.Name......!
My DAO solution is this :
If you select in your Reference Library Microsoft DAO 3.xx you can use:
FullPath=CurrentDb.Name
Here you have the full Path, now to obtain the DirOnly you can use this
function and call it like this:
Path=GetPathPart(CurrentDb.Name)
FileName=ParseFileName(CurrentDb.Name)
Public Function GetPathPart(ByVal strPath As String) As String
'*****************************************************************
'Name : GetPathPart (Function)
'Purpose : Return Path name ONLY
'Author : Alessandro Baraldi
'Called by :
'Calls :
'Inputs : strPath="C:\Programmi\DataBase.mdb"
'Output : GetPathPart="C:\Programmi\"
'*****************************************************************
Dim intCounter As Integer
For intCounter = Len(strPath) To 1 Step -1
If Mid$(strPath, intCounter, 1) = "\" Then
Exit For
End If
Next intCounter
GetPathPart = Left$(strPath, intCounter)
End Function
Public Function ParseFileName(ByVal FileName As String) As String
'*****************************************************************
'Name : ParseFileName (Function)
'Purpose : Return File Name ONLY
'Author : Alessandro Baraldi
'Date : 23 gennaio 2002
'Called by :
'Calls :
'Inputs : strFileName="C:\Programmi\DataBase.mdb"
'Output : ParseFileName="Database.mdb"
'*****************************************************************
On Error GoTo Err_ParseFileName
ParseFileName = Dir(FileName)
Exit_ParseFileName:
Exit Function
Err_ParseFileName:
MsgBox Err.Description
Resume Exit_ParseFileName
End Function
Bye.
@Alex.