共用方式為


Form.CommandBeforeExecute 事件 (Access)

發生於指定的命令執行之前。 當您希望在特定的命令執行前使用特定限制,請使用此事件。

語法

運算式CommandBeforeExecute (CommandCancel)

expression 代表 Form 物件的變數。

參數

名稱 必要/選用 資料類型 描述
Command 必要 Variant 將執行的命令。
Cancel 必要 Object 此物件的 Value 屬性設 為 True 可取消命令。

傳回值

註解

OCCommandIdChartCommandIdEnumPivotCommandId常數包含每個 Microsoft Office Web 元件支援的命令清單。

範例

下列範例示範擷取 CommandBeforeExecute 事件的副程式的語法。

Private Sub Form_CommandBeforeExecute( _ 
 ByVal Command As Variant, ByVal Cancel As Object) 
 Dim intResponse As Integer 
 Dim strPrompt As String 
 
 strPrompt = "Cancel the command?" 
 
 intResponse = MsgBox(strPrompt, vbYesNo) 
 
 If intResponse = vbYes Then 
 Cancel.Value = True 
 Else 
 Cancel.Value = False 
 End If 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應