Q: Programmatically create a folder from MS-Access?

M

MarkD

Using Access 2000.

Hey,

I need to create a folder on a click event. What's the
function for that and do I have to include any references,
or APIs?

Also, if you find an answer, could you tell me how you
found it? I tried searching on the MS-knowledge base and
couldn't find anything.

Thanks,
-Mark
 
M

MarkD

Just figured it out.

For those curious:

Sub CreateFolder(strID As String)
'Add Scripting Object reference
Dim fso As New Scripting.FileSystemObject
Dim strPath As String

strPath = GetMDBPath
strPath = strPath & strID


If fso.FolderExists(strPath) Then
MsgBox ("folder " & strPath & " already exists.")
Else
fso.CreateFolder (strPath)
End If

Set fso = Nothing

End Sub
 
D

Douglas J. Steele

No need to use FSO. VBA has the necessary functionality built in.

Sub CreateFolder(strID As String)
Dim strPath As String

strPath = GetMDBPath
strPath = strPath & strID


If Len(Dir(strPath, vbDirectory)) > 0 Then
MsgBox ("folder " & strPath & " already exists.")
Else
MkDir strPath
End If

End Sub
 

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