[AccessD] Common Dialog

Heenan, Lambert Lambert.Heenan at chartisinsurance.com
Thu Jan 7 11:21:28 CST 2010


Here's a simple function to return the file path...

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
        GetPath = left$(aPath, aSlash)
    Else
        GetPath = ""
    End If
End Function

And using that you can get the file name...

Function GetFileName(aPath) As String
Dim fPath As String
    fPath = GetPath(aPath)
    If Len(fPath) = Len(aPath) Then ' only a path was provided
        GetFileName = ""
    Else
        GetFileName = right$(aPath, Len(aPath) - Len(fPath))
    End If
End Function

These two functions were written back in Access 97 days, before the Split() function came to be. With split you could do something like this (air code)...

Function GetFileName(sPath as String) as String
vArray as Variant
	vArray = Split(sPath,"\")
	GetFileName = Cstr(Ubound(vArray))
End Function
 

Lambert

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Lawrence Mrazek
Sent: Thursday, January 07, 2010 12:00 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] Common Dialog

Hi Folks:

I'm the API from http://www.mvps.org/access/api/api0001.htm, and can't seem to remember how to ONLY retrieve the filename (not the filename and path using the API. 

I suppose that if I know the directory, I can use some functions to trim off the directory path, but in this case I might not always be looking for the files in a default directory.

Any hints/guidance would be appreciated. 

Larry Mrazek
lmrazek at lcm-res.com
314-432-5886



--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list