MKDIR Limitations

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

Guest

This statement works
MkDir Path & Me.[Last Name] & "_" & Me.[First Name]


But this one does not.
MkDir Path & Me.[Last Name] & "_" & Me.[First Name] & "\" & Me.Class


Is there a limit to how many levels I can go using mkdir statement? Or am I
just not seeing something?
If there is a 1 folder limit, any suggestions to make a director 2 levels
down?
 
MkDir works only to make a subfolder within the current folder. Use ChDir to
move to the desired folder and then make a folder within it.
 
As Ken says, MkDir can only create one level of folder at a time.

Randy Birch shows a couple of techniques to extend this at
http://vbnet.mvps.org/code/file/nested.htm

(Obligatory note: Randy's site is aimed at VB programmers. There are
significant differences in the controls available for forms in VB vs. those
available in Access. Consequently, GUI-related code in his examples don't
always port exactly to Access. This example is one of those cases: he's
manually adding items to a listbox, and that won't work in most versions of
Access)
 
David,

There is an API that will create the entire path for you in one go.

Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal
lpPath As String) As Long

For example:
MakeSureDirectoryPathExists "c:\this\is\a\test\directory\"

....will create all the directories in the specified path, beginning with the
root.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Back
Top