[AccessD] Get path from full file name

Gustav Brock gustav at cactus.dk
Thu Oct 23 10:50:16 CDT 2003


Hi Lambert

I may be wrong but to me

  \\fs1\sys\database\client1\somedb.mdb

is a valid full path and filename. Access thinks so too as you can
open or link to a database using such a path/filename.

And if you wish to, say, export a file to the current dir of drive c:

  c:report.xls

is valid as a relative path/filename although I would recommend an
absolute path/filename.

/gustav


> Hello Gustav,

> "You didn't run any test on it, did you?" - that's a pretty big assumption
> isn't it? I did run test and got the same results as you did, with those two
> exceptions, which I managed to overlook. <g>

> <pedant mode>
> Strictly speaking, the drive letter and the server name are not part of the
> file path in any case. The path is the route of folders that must be
> traversed to reach the file on the storage device,
> </pedant mode>
> but if you want to emulate the results of your routine, here's a simple
> modification of mine...

> Function GetPath(aPath) As String
> ' Strips the path name from the supplied file and path name
> ' leaves the trailing slash on there
> Dim foo As Integer, aSlash As Integer
>     aSlash = 0
>     foo = InStr(aPath, "\")
>     While (foo > 0)
>         aSlash = foo
>         foo = InStr(aSlash + 1, aPath, "\")
>     Wend
>     If aSlash > 0 Then
>         If aSlash = 2 Then
>             GetPath = aPath
>         Else
>             GetPath = Left$(aPath, aSlash)
>         End If
>     Else
>         If (Left(UCase(aPath), 1) >= "A" And Left(UCase(aPath), 1) <= "Z") _
>             And Mid(aPath, 2, 1) = ":" Then
>             GetPath = Left(aPath, 2)
>         Else
>           GetPath = aPath
>         End If
>     End If
> End Function

> BTW, did you check out the InstrR() function for A97?

> Lambert
>> -----Original Message-----
>> From: Gustav Brock [SMTP:gustav at cactus.dk]
>> Sent: Thursday, October 23, 2003 3:25 AM
>> To:   Heenan, Lambert
>> Subject:      [AccessD] Get path from full file name
>> 
>> Hi Lambert
>> 
>> You didn't run any test on it, did you?
>> 
>> It is similar to the quickies found many places and it fails for paths
>> like "\\fs1" and "c:file".
>> 
>> /gustav



More information about the AccessD mailing list