MS Access CurDir() Function
The CurDir()
function in MS Access retrieves the current directory path, either for the current drive or a specific drive that you specify.
CurDir(): Definition and Usage
This function is helpful for obtaining information about file locations within your Access application. It's frequently used in VBA (Visual Basic for Applications) code to work with files stored on the user's computer.
Syntax
Syntax
CurDir(drive)
Parameter Values
Parameter | Description |
---|---|
drive (Optional) |
A string representing the drive letter (e.g., "C", "D"). If omitted, it returns the path of the current drive. |
Examples
Getting the Current Directory
Without specifying a drive, this returns the path of the currently active drive.
Syntax
CurDir()
Output
C:\Documents and Settings\user\My Documents (Example; this will vary depending on the user's system)
Getting the Directory of a Specific Drive
This shows how to get the path for drive D:.
Syntax
CurDir("D")
Output
D:\ (or the root directory of drive D if it's not mapped)