DeleteObject Method

Applies To

DoCmd Object.

Description

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

Syntax

DoCmd.DeleteObject [objecttype, objectname]

The DeleteObject method uses the following arguments.

Argument Description
objecttype One of the following intrinsic constants:

acTable
acQuery
acForm
acReport
acMacro
acModule

objectname A string expression that is the valid name of an object of the type selected with the objecttype argument.
If you run Visual Basic code containing the DeleteObject 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 objectname arguments blank, Microsoft Access deletes 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).

See Also

DeleteObject Action, DoCmd Object, SelectObject Method.

Example

This example deletes the specified table.


DoCmd.DeleteObject acTable, "Former Employees Table"