Rename Method

Microsoft Access Visual Basic

action in Visual Basic.

expression.Rename(NewName, ObjectType, OldName)

expression    Required. An expression that returns a DoCmd object.

NewName   Required Variant. 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   Optional AcObjectType. The type of object to rename.

AcObjectType can be one of these AcObjectType constants.
acDataAccessPage
acDefault default
acDiagram
acForm
acFunction
acMacro
acModule
acQuery
acReport
acServerView
acStoredProcedure
acTable

OldName   Optional Variant. 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

For more information on how the action and its arguments work, see the action topic.

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.

Example

The following example renames the Employees table.

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