Parse a path for a file name in Access

C

CK

Hi All,
How do I parse a file path in Access for return the file name?
Example
c:\somefolder\somefolder\somefolder\somefolder\somefolder\somefolder\somefolder\someFile.xls
I want to query a table with this value and just return 'someFile.xls" no
matter how long or short the path is. I can do this in SQL Server, but i am
new to Access SQL and I can not figure it quite out.
Any help is always appreciated.

Cheers,
~ck
 
F

fredg

Hi All,
How do I parse a file path in Access for return the file name?
Example
c:\somefolder\somefolder\somefolder\somefolder\somefolder\somefolder\somefolder\someFile.xls
I want to query a table with this value and just return 'someFile.xls" no
matter how long or short the path is. I can do this in SQL Server, but i am
new to Access SQL and I can not figure it quite out.
Any help is always appreciated.

Cheers,
~ck

Mid([FieldName],InStrRev([FieldName],"\")+1)
should return everything after the rightmost "\".
 
D

Daniel Pineault

Try somethinglike:

strFileWPath = "c:\tmp\temp\excel.xls"
strFileName = Right(strFileWPath,len(strFileWPath)-instrRev(strFileWPath,"\"))
--
Hope this helps,

Daniel Pineault
If this post was helpful, please rate it by using the vote buttons.
 
B

Bob Quintal

Hi All,
How do I parse a file path in Access for return the file name?
Example
c:\somefolder\somefolder\somefolder\somefolder\somefolder
\somefolde> r\somefolder\someFile.xls

I want to query a table with this value
and just return 'someFile.xls" no matter how long or short the
path is. I can do this in SQL Server, but i am new to Access SQL
and I can not figure it quite out. Any help is always appreciated.

Cheers,
~ck

The VB dir() function has a useful feature in that if you pass the
fully qualified path+file name, it will return the file name without
the path.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top