Rename Action

Description

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

Setting

The Rename action uses the following arguments.

Action argument

Description

New Name

A new name for the database object. This is a required argument.

Object Type

The type of object you want to rename. Click Table, Query, Form, Report, Macro, or Module in the Object Type box in the Action Arguments section of the Macro window. To rename the object selected in the Database window, leave this argument blank.

Old Name

The name of the object to be renamed. The Old Name box shows all objects in the database of the type selected by the Object Type argument. If you leave Object Type blank, leave this argument blank also.


Note If you run a macro containing the Rename action in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.

Remarks

The new name of the database object must follow the standard naming conventions for Microsoft Access objects.

You cannot rename an open object.

If you leave the Object Type and Old Name arguments blank, Microsoft Access renames the object selected in the Database window. To select an object in the Database window, you can use the SelectObject action with the In Database Window argument set to Yes. You can also select an object by clicking it the Database window, clicking it again so you can edit its name, and entering a new name. With the Rename action, you don’t have to select the object first in the Database window, and you don’t have to stop the macro to enter the new name.

This action differs from the CopyObject action, which creates a copy of the object under a new name.

To run the Rename action in Visual Basic, use the Rename method of the DoCmd object.

See Also

CopyObject Action, Rename Method, SelectObject Action.