Jurgen Welz
jwelz at hotmail.com
Sat Jan 16 19:17:51 CST 2010
You should test that a string has been passed and make sure there is a backslash somewhere in the path and add any other error handling you need. Function fnLastPath(strPathIn As String) As String Dim lngLen As Long Dim lngPos As Long Dim strReturn As String lngLen = Len(strPathIn) lngPos = InStrRev(strPathIn, "\") If lngPos = lngLen Then strPathIn = Left$(strPathIn, lngLen - 1) lngPos = InStrRev(strPathIn, "\") strReturn = Mid$(strPathIn, lngPos + 1) Else strReturn = Mid$(strPathIn, lngPos + 1) End If fnLastPath = strReturn End Function Ciao Jürgen Welz Edmonton, Alberta jwelz at hotmail.com > From: robert at servicexp.com > To: accessd at databaseadvisors.com > Date: Sat, 16 Jan 2010 19:06:22 -0500 > Subject: [AccessD] Simple String Help > > I know this should be easy, but for some reason today I just can't come up > with a working solution.. > > > The Goal: To evaluate a string (path) and return only the end (last folder > name). > > This string could end differently with or without "\" > > Example: "\\adfs\ad_folder\sxpdata\Word Docs\" OR > "\\adfs\ad_folder\sxpdata\Word Docs OR C:\ad_folder\sxpdata\Word Doc\ > > Need to return only the "Word Docs" portion > > I'm drawing a blank here.... > > > WBR > Robert _________________________________________________________________