totn Access Functions

MS Access: ChDrive Statement

This MSAccess tutorial explains how to use the Access ChDrive statement with syntax and examples.

Description

The Microsoft Access ChDrive statement allows you to change the current drive.

Syntax

The syntax for the ChDrive statement in MS Access is:

ChDrive drive

Parameters or Arguments

drive
The drive that you wish to change to.

Returns

The ChDrive statement does not return a value, but rather changes the current drive.

Note

  • If you need to change the current directory as well, try using the ChDir statement.

Applies To

The ChDrive statement 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 ChDrive function in MS Access:

ChDrive "S"
Result: Sets the current drive to S

ChDrive "C"
Result: Sets the current drive to C

Example in VBA Code

The ChDrive statement can be used in VBA code in Microsoft Access.

For example:

ChDrive "S"

ChDir "S:\Games"

In this example, the current drive is set to the S drive. Then the current directory is set to S:\Games.