Home page
or browse popular tags
Access Functions

Sign up for the free email newsletter for new tips, tutorials and more. Enter your email address below, and then click the button.

Privacy Policy

RSS Twitter

Access: CurDir Function


In Access, the CurDir function returns a string containing the full path of the specified drive. 

The syntax for the CurDir function is:

CurDir ( drive )

The optional drive argument is a string expression that specifies an existing drive. If this parameter is omitted or it is a zero-length string (""), CurDir returns the path for the current drive.


CurDir ()             returns "C:\Documents and Settings\UserName\My Documents"
CurDir ( "H" )        returns "H:\"

VBA Code

Dim MyPath As String 
MyPath = CurDir ()

This example uses the CurDir function to return the current path. Now the MyPath variable would contain the value "C:\Documents and Settings\UserName\My Documents".

SQL query

You can also use the CurDir function in a query.

SELECT CurDir() AS Expr1
FROM Orders


This function cannot be used or referenced in expressions when Access is operating in sandbox mode, but they can be used in Microsoft Visual Basic for Applications (VBA) code. To enable the CurDir function in expressions or SQL statements, add the following code to a code module in the Visual Basic Editor in Access:

Public Function CurDir(Optional Drive As String)
CurDir = VBA.CurDir(Drive)
End Function


Add To: Add to dzone dzone | Digg this digg | Add to del.icio.us del.icio.us | Stumble it stumbleupon

  • Comments

Copyright © 2005-2023             www.WebCheatSheet.com All Rights Reserved.