Create and/or Open Folder in Explorer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'd like to be able to add a button to a form so that miscellaneous files can
be "tied" to a specific record only when necessary. What I'd like it to do
when the button is clicked is to:

1. Check to see there is a folder in a specific path with the value in the
field "LOG NUMBER" as the final subfolder. So ... is there a folder by the
name of:

\Cpsvw2-a001\public\BOS_Corrective & Preventive Action\"LOG NUMBER"

2. If not, create the folder.
3. Open the folder.

Can someone please help? Thanks!
Cindy
 
Thanks, Ken. I'm a beginner with VBA ... but I used the help to build the
following code:

Dim chkName As String

chkName = "c:\Innatech\8D Database\" & Me.LogNumber
If Dir(chkName) = "" Then
MkDir (chkName)
End If

....which worked great when the directory DIDN'T exist, but gave me run-time
error '75' (Path/File access error) when the directory did exist. Can you
please help with what I missed? I couldn't tell how to indicate I was
looking just for a directory and not for any files....

Also, once I've got the directory how do I open up Windows Explorer for that
directory?

Thanks so much for your help.

Cindy
 
To test for a folder, use vbDirectory as the second argument in the Dir
function::

chkName = "c:\Innatech\8D Database\" & Me.LogNumber
If Dir(chkName, vbDirectory) = "" Then
MkDir (chkName)
End If

I don't know how to cause Windows Explorer to open for that folder when it
exists, but I would anticipate that you might be able to use the Shell
function. I suggest that you post this WE question in a new post where
someone with more knowledge than I might see and respond to the question.
--

Ken Snell
<MS ACCESS MVP>
 
Okay. Thanks, Ken.

Ken Snell (MVP) said:
To test for a folder, use vbDirectory as the second argument in the Dir
function::

chkName = "c:\Innatech\8D Database\" & Me.LogNumber
If Dir(chkName, vbDirectory) = "" Then
MkDir (chkName)
End If

I don't know how to cause Windows Explorer to open for that folder when it
exists, but I would anticipate that you might be able to use the Shell
function. I suggest that you post this WE question in a new post where
someone with more knowledge than I might see and respond to the question.
 
Back
Top