Table of contents
TOC
Collapse the table of content
Expand the table of content

DoCmd.Rename Method (Access)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

The Rename method carries out the Rename action in Visual Basic.

Syntax

expression. Rename( ** NewName, ** ObjectType, ** OldName** )

expression A variable that represents a DoCmd object.

Parameters

NameRequired/OptionalData TypeDescription
NewNameRequiredVariantA 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.
ObjectTypeOptionalAcObjectTypeA AcObjectType constant that specifies the type of object to rename. The default value is acDefault.
OldNameOptionalVariantA 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

You can use the Rename method to rename a specified database object.

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 method with the In Database Window argument set to Yes ( True ).

Example

The following example renames the Employees table.

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

See also

Concepts

DoCmd Object

© 2018 Microsoft