Author: Calvin Smith
http://www.CalvinSmithSoftware.com/codedisk/sneakpeek.htm

The following code will allow a developer to programmatically
parse a filename from a path.


Function ParseFileNameFromPath(strPathAndFileName As String) As String

' ---------------------------------------------------------------------------------
' Author: Calvin Smith - JobForCalvin@Yahoo.com
' Environment(s): MS Access (32-bit) / Visual Basic (32-bit)
' ---------------------------------------------------------------------------------
'
'   *****************************************
'   * Courtesy code from my CodeDisk© product
'   *****************************************
   '
   ' ----------------------------------------------------------------------------
   ' Purpose: Example of how to parse a filename from a full path
   '
   ' Accepts: strPathAndFileName as the fully qualified path and filename
   '
   ' Returns: The parsed filename
   '
   ' Example: strRetVal = ParseFileNameFromPath("C:\CodeDisk\CodeDisk.exe")
   ' ----------------------------------------------------------------------------
   '
On Error GoTo ErrorHandling_Err

          Dim iFoundWhere As Integer

          Dim iReStartHere As Integer

          ParseFileNameFromPath$ = strPathAndFileName$

          iFoundWhere% = InStr(strPathAndFileName$, "\")

          Do While iFoundWhere%

                    iReStartHere% = iFoundWhere%
                    iFoundWhere% = InStr(iReStartHere% + 1, strPathAndFileName$, "\")

          Loop

          If iReStartHere% > 0 Then ParseFileNameFromPath$ = _
                    Mid$(strPathAndFileName$, iReStartHere% + 1)

ErrorHandling_Exit:
   Exit Function

ErrorHandling_Err:

   If Err Then
       MsgBox Err.Description
       Resume ErrorHandling_Exit
   End If

End Function