DoCmd 方法 (Access) DeleteObjectDoCmd.DeleteObject method (Access)

在 Visual Basic 中, DeleteObject方法执行 DeleteObject 操作。The DeleteObject method carries out the DeleteObject action in Visual Basic.

语法Syntax

表达式DeleteObject(ObjectType, ObjectName)expression.DeleteObject (ObjectType, ObjectName)

_表达式_一个代表**DoCmd** 对象的变量。expression A variable that represents a DoCmd object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
ObjectTypeObjectType 可选Optional AcObjectTypeAcObjectType 一个AcObjectType常量, 该常量代表要删除的对象的类型。An AcObjectType constant that represents the type of object to delete.
ObjectNameObjectName 可选Optional VariantVariant 字符串表达式, 表示由_ObjectType_参数选择的类型的对象的有效名称。A string expression that's the valid name of an object of the type selected by the ObjectType argument. 如果在类库数据库中运行包含DeleteObject方法的 Visual Basic 代码, Microsoft Access 将先在该类库数据库中查找具有此名称的对象, 然后再在当前数据库中查找。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, and then in the current database.

注解Remarks

DeleteObject 方法可删除指定的数据库对象。You can use the DeleteObject method to delete a specified database object.

如果将_objecttype_和_ObjectName_参数保留为空 (默认常量, acDefault, 则假定为_ObjectType_), Access 将删除在数据库窗口中选定的对象。If you leave the ObjectType and ObjectName arguments blank (the default constant, acDefault, is assumed for ObjectType), Access deletes the object selected in the Database window. 若要在 "数据库" 窗口中选择对象, 可以使用 SelectObject 操作或SelectObject方法, 并将_InDatabaseWindow_参数设置为 "是 (True)"。To select an object in the Database window, you can use the SelectObject action or SelectObject method with the InDatabaseWindow argument set to Yes (True).

示例Example

下面的示例删除指定的表格。The following example deletes the specified table.

DoCmd.DeleteObject acTable, "Former Employees Table"

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.