Application.DeleteReportControl 方法 (Access)
DeleteReportControl 方法从报表中删除指定的控件。
语法
表达式。DeleteReportControl (ReportName、 ControlName)
expression:表示 Application 对象的变量。
参数
名称 | 必需/可选 | 数据类型 | 说明 |
---|---|---|---|
ReportName | 必需 | 字符串 | 包含要删除的控件的报表的名称。 |
ControlName | 必需 | 字符串 | 要删除的控件的名称。 |
返回值
Nothing
注解
DeleteReportControl 方法是分别仅在窗体设计视图或报表设计视图中可用。
注意
如果正建立一个从窗体或报表中删除控件的向导,该向导必须先在“设计”视图中打开这个窗体或报表,然后才能删除控件。
示例
下面的示例创建带有命令按钮的窗体,并且显示提示信息询问用户是否要删除这个命令按钮。 如果用户选择 “是”,则会删除命令按钮。
Sub DeleteCommandButton()
Dim frm As Form, ctlNew As Control
Dim strMsg As String, intResponse As Integer, _
intDialog As Integer
' Create new form and get pointer to it.
Set frm = CreateForm
' Create new command button.
Set ctlNew = CreateControl(frm.Name, acCommandButton)
' Restore form.
DoCmd.Restore
' Set caption.
ctlNew.Caption = "New Command Button"
' Size control.
ctlNew.SizeToFit
' Prompt user to delete control.
strMsg = "About to delete " & ctlNew.Name &". Continue?"
' Define buttons to be displayed in dialog box.
intDialog = vbYesNo + vbCritical + vbDefaultButton2
intResponse = MsgBox(strMsg, intDialog)
If intResponse = vbYes Then
' Delete control.
DeleteControl frm.Name, ctlNew.Name
End If
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。