Solved

Extract Just Path Location from File Picker  vba Access

Posted on 2016-08-17
3
51 Views
Last Modified: 2016-08-17
vba

Using

' To extract only the filename from the path, you can do the following:
   varFilename = Mid(fDialog.SelectedItems(1), InStrRev(fDialog.SelectedItems(1), "\") + 1, Len(fDialog.SelectedItems(1)))
  

Open in new window


The Above gives me
myexcelfile.xls
from
C:\Program Files\MyData\myexcelfile.xls



What I need:
I need to extract just the file Path Location :
C:\Program Files\MyData\

This will not work: it gives me the whole file location path and name:  C:\Program Files\MyData\myexcelfile.xls



thanks
fordraiders
0
Comment
Question by:fordraiders
3 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 41759835
try:

varPath = LEFT(fDialog.SelectedItems(1), InStrRev(fDialog.SelectedItems(1), "\"))
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 41759838
Try this:
   varPath = Left(fDialog.SelectedItems(1), Len(fDialog.SelectedItems(1)) - InStrRev(fDialog.SelectedItems(1), "\") - 1, )
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 41759941
Thanks dale.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question