totn Access Functions

MS Access: CurDir Function

This MSAccess tutorial explains how to use the Access CurDir function with syntax and examples.

Description

The Microsoft Access CurDir function returns the current path.

Syntax

The syntax for the CurDir function in MS Access is:

CurDir ( drive )

Parameters or Arguments

drive
Optional. If this parameter is omitted, the CurDir function assumes the current drive.

Applies To

The CurDir function can be used in the following versions of Microsoft Access:

  • Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000

Example

Let's look at how to use the CurDir function in MS Access:

CurDir ()
Result: "C:\Documents and Settings\user\My Documents"

CurDir ("G")
Result: "G:\"

Example in VBA Code

The CurDir function can be used in VBA code in Microsoft Access.

For example:

Dim LResult As String

LResult = CurDir ()

In this example, the variable called LResult would now contain the value "C:\Documents and Settings\user\My Documents".

Example in SQL/Queries

You can also use the CurDir function in a query in Microsoft Access.

For example:

Microsoft Access

In this query, we have used the CurDir function as follows:

Expr1: CurDir()

This query will return the current path and display the results in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.

For example:

CurrentDirectory: CurDir()

The results would now be displayed in a column called CurrentDirectory.