Opening a folder with a command button without hardcoding path

  • Thread starter Thread starter SeanCly10
  • Start date Start date
S

SeanCly10

Hi all,

I'm working on integrating several functions of my work into one Access
database, and I've run into a solid wall.

What I want to do is create a command button on a form that will open a
particular folder. The catch is, I don't want to have to hardcode the
path in the VB for the button. I know that there's a way to code it so
that it searches for the unique folder name and then opens it, but I
don't have a clue how to do it. Can someone help?

Thanks,
Sean
 
Hi Sean.

Hi all,

I'm working on integrating several functions of my work into one Access
database, and I've run into a solid wall.

What I want to do is create a command button on a form that will open a
particular folder. The catch is, I don't want to have to hardcode the
path in the VB for the button. I know that there's a way to code it so
that it searches for the unique folder name and then opens it, but I
don't have a clue how to do it. Can someone help?

strFolder = "C:\ThisIsTheFolder"
Shell "Explorer " & strFolder, vbNormalFocus
 
.... and what do you mean by "the unique folder name"?

Unique here means that you have an algorithm to finf it but you need to
instruct the PC to find it and for us to be able to suggext, we need to know
this algo. also.
 
Van said:
... and what do you mean by "the unique folder name"?

Unique here means that you have an algorithm to finf it but you need to
instruct the PC to find it and for us to be able to suggext, we need to know
this algo. also.

I'm not sure what you mean by algorithm. What I'm trying to do is to
create a command button that, when clicked, opens a certain folder on
the PCs hard drive, independent of Access. I don't want to have to hard
code the folder's path in the VB, just the folder's name. Like, if my
folder is named 'MyFolder', I want to have the code look for that
folder name on the hard drive, then open it for viewing.
 
That's not a unique directory name!

You can have 2 or more different directory with the same name being
sub-directories of different directory.

Check Access VBA Help on the Dir() function which can give you
(sub-)directory names of the root dir or any dir ...
 
Back
Top