find in vba a position from a specific character in a access filed

hi

i have a field that stored files location like this: c:\users\user\sample.

and i want that access will cut the whole file location and leave only the file name ,like the file name "sample" so i need that access will get start search from the last character by the right side and to find if there is a Backslash
and if not to go to the next character from the right side and so on and when it's will find the first backslash to give me the position.

thanks a lot
bill201Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin SparksCommented:
The functions below will assist you.

Please note that I sourced these from

http://www.vbaexpress.com/kb/getarticle.php?kb_id=767

Kelvin
Option Explicit 
 
 'The following function returns the filename without the extension from the file's full path:
Function FileNameNoExt(strPath As String) As String 
    Dim strTemp As String 
    strTemp = Mid$(strPath, InStrRev(strPath, "\") + 1) 
    FileNameNoExt = Left$(strTemp, InStrRev(strTemp, ".") - 1) 
End Function 
 
 'The following function returns the filename with the extension from the file's full path:
Function FileNameWithExt(strPath As String) As String 
    FileNameWithExt = Mid$(strPath, InStrRev(strPath, "\") + 1) 
End Function 
 
 'the following function will get the path only (i.e. the folder) from the file's ful path:
Function FilePath(strPath As String) As String 
    FilePath = Left$(strPath, InStrRev(strPath, "\")) 
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bill201Author Commented:
Thanks a lot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.