Rename Method

Applies To   DoCmd object.

Description

The Rename method carries out the Rename action in Visual Basic. For more information on how the action and its arguments work, see the action topic.

Syntax

DoCmd.Rename newname[, objecttype, oldname]

The Rename method has the following arguments.

Argument

Description

newname

A string expression that's the new name for the object you want to rename. The name must follow the object-naming rules for Microsoft Access objects.

objecttype

One of the following intrinsic constants:

acDefault (default)
acForm
acMacro
acModule
acQuery
acReport
acTable

oldname

A string expression that's the valid name of an object of the type specified by the objecttype argument.

If you execute Visual Basic code containing the Rename method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.


Remarks   If you leave the objecttype and oldname arguments blank (the default constant, acDefault, is assumed for objecttype), Microsoft Access renames the object selected in the Database window. To select an object in the Database window, you can use the SelectObject action or SelectObject method with the In Database Window argument set to Yes (True).

If you leave the objecttype and oldname arguments blank, don't use a comma following the newname argument.

See Also   CopyObject method, DoCmd object, Rename action, Save method, SelectObject method.

Example

The following example renames the Employees table with the specified name:

DoCmd.Rename "Old Employees Table", acTable, "Employees"