(Scroll to see more)
- Concat with &
- Format (with Dates)
- Format (with Numbers)
- Format (with Strings)
- Rnd (random number)
MS Access: MkDir Statement
Learn how to use the Access MkDir function with syntax and examples.
The Microsoft Access MkDir statement allows you to create a new folder or directory.
The syntax for the Microsoft Access MkDir statement is:
Parameters or Arguments
path is the folder or directory to create.
If path is a complex directory structure, the high-level directories must already exist or the MkDir statement will raise an error.
For example, if you executed the following code:
The c:\Test directory must already exist. The MkDir statement will only attempt to create the Access directory under the c:\Test directory. It will not create the c:\Test directory itself.
The MkDir statement can be used in the following versions of Microsoft Access:
- Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000
In this example, the MkDir statement would create a new directory called Examples under the c:\TOTN directory.
Example (in VBA Code)
The MkDir statement can be used in VBA code in Microsoft Access. For example:
In this example, the directory called Files would be created under the c:\TOTN\Examples directory.
Frequently Asked Questions
Question: I'm not sure if a particular directory exists already. If it doesn't exist, I'd like to create it using VBA code. How can I do this?
Answer: You can test to see if a directory exists using the VBA code below:
If Len(Dir("c:\TOTN\Examples", vbDirectory)) = 0 Then MkDir "c:\TOTN\Examples" End If
In this example, the code would first check to see if the c:\TOTN\Examples directory exists. If it doesn't exist, the MkDir statement would create a new directory called Examples under the c:\TOTN directory.