RunCommand 方法

expandtri全部显示

RunCommand 方法用于执行内置菜单命令或内置工具栏命令。

expression.RunCommand(Command)

expression     必需。返回“应用于”列表中的一个对象的表达式。

Command     AcCommand,必需。固有常量,指定要执行的内置菜单命令或内置工具栏命令。

AcCommand 可以是下列 AcCommand 常量之一:

acCmdAboutMicrosoftAccess

acCmdAddInManager

acCmdAddToNewGroup

acCmdAddWatch

acCmdAdvancedFilterSort

acCmdAlignBottom

acCmdAlignCenter

acCmdAlignLeft

acCmdAlignmentAndSizing

acCmdAlignMiddle

acCmdAlignRight

acCmdAlignToGrid

acCmdAlignTop

acCmdAlignToShortest

acCmdAlignToTallest

acCmdAnalyzePerformance

acCmdAnalyzeTable

acCmdAnswerWizard

acCmdApplyDefault

acCmdApplyFilterSort

acCmdAppMaximize

acCmdAppMinimize

acCmdAppMove

acCmdAppRestore

acCmdAppSize

acCmdArrangeIconsAuto

acCmdArrangeIconsByCreated

acCmdArrangeIconsByModified

acCmdArrangeIconsByName

acCmdArrangeIconsByType

acCmdAutoCorrect

acCmdAutoDial

acCmdAutoFormat

acCmdBackgroundPicture

acCmdBackgroundSound

acCmdBackup

acCmdBookmarksClearAll

acCmdBookmarksNext

acCmdBookmarksPrevious

acCmdBookmarksToggle

acCmdBringToFront

acCmdCallStack

acCmdChangeToCheckBox

acCmdChangeToComboBox

acCmdChangeToCommandButton

acCmdChangeToImage

acCmdChangeToLabel

acCmdChangeToListBox

acCmdChangeToOptionButton

acCmdChangeToTextBox

acCmdChangeToToggleButton

acCmdChartSortAscByTotal

acCmdChartSortDescByTotal

acCmdClearAll

acCmdClearAllBreakpoints

acCmdClearGrid

acCmdClearHyperlink

acCmdClearItemDefaults

acCmdClose

acCmdCloseWindow

acCmdColumnWidth

acCmdCompactDatabase

acCmdCompileAllModules

acCmdCompileAndSaveAllModules

acCmdCompileLoadedModules

acCmdCompleteWord

acCmdConditionalFormatting

acCmdConnection

acCmdControlWizardsToggle

acCmdConvertDatabase

acCmdConvertMacrosToVisualBasic

acCmdCopy

acCmdCopyDatabaseFile

acCmdCopyHyperlink

acCmdCreateMenuFromMacro

acCmdCreateRelationship

acCmdCreateReplica

acCmdCreateShortcut

acCmdCreateShortcutMenuFromMacro

acCmdCreateToolbarFromMacro

acCmdCut

acCmdDataAccessPageAddToPage

acCmdDataAccessPageBrowse

acCmdDataAccessPageDesignView

acCmdDataAccessPageFieldListRefresh

acCmdDatabaseProperties

acCmdDatabaseSplitter

acCmdDataEntry

acCmdDataOutline

acCmdDatasheetView

acCmdDateAndTime

acCmdDebugWindow

acCmdDelete

acCmdDeleteGroup

acCmdDeletePage

acCmdDeleteQueryColumn

acCmdDeleteRecord

acCmdDeleteRows

acCmdDeleteTab

acCmdDeleteTable

acCmdDeleteTableColumn

acCmdDeleteWatch

acCmdDemote

acCmdDesignView

acCmdDiagramAddRelatedTables

acCmdDiagramAutosizeSelectedTables

acCmdDiagramDeleteRelationship

acCmdDiagramLayoutDiagram

acCmdDiagramLayoutSelection

acCmdDiagramModifyUserDefinedView

acCmdDiagramNewLabel

acCmdDiagramNewTable

acCmdDiagramRecalculatePageBreaks

acCmdDiagramShowRelationshipLabels

acCmdDiagramViewPageBreaks

acCmdDocMaximize

acCmdDocMinimize

acCmdDocMove

acCmdDocRestore

acCmdDocSize

acCmdDocumenter

acCmdDropSQLDatabase

acCmdDuplicate

acCmdEditHyperlink

acCmdEditingAllowed

acCmdEditRelationship

acCmdEditTriggers

acCmdEditWatch

acCmdEncryptDecryptDatabase

acCmdEnd

acCmdExit

acCmdExport

acCmdFavoritesAddTo

acCmdFavoritesOpen

acCmdFieldList

acCmdFilterByForm

acCmdFilterBySelection

acCmdFilterExcludingSelection

acCmdFind

acCmdFindNext

acCmdFindNextWordUnderCursor

acCmdFindPrevious

acCmdFindPrevWordUnderCursor

acCmdFitToWindow

acCmdFont

acCmdFormatCells

acCmdFormHdrFtr

acCmdFormView

acCmdFreezeColumn

acCmdGoBack

acCmdGoContinue

acCmdGoForward

acCmdGroupByTable

acCmdGroupControls

acCmdHideColumns

acCmdHidePane

acCmdHideTable

acCmdHorizontalSpacingDecrease

acCmdHorizontalSpacingIncrease

acCmdHorizontalSpacingMakeEqual

acCmdHyperlinkDisplayText

acCmdImport

acCmdIndent

acCmdIndexes

acCmdInsertActiveXControl

acCmdInsertChart

acCmdInsertFile

acCmdInsertFileIntoModule

acCmdInsertHyperlink

acCmdInsertLookupColumn

acCmdInsertLookupField

acCmdInsertMovieFromFile

acCmdInsertObject

acCmdInsertPage

acCmdInsertPicture

acCmdInsertPivotTable

acCmdInsertProcedure

acCmdInsertQueryColumn

acCmdInsertRows

acCmdInsertSpreadsheet

acCmdInsertSubdatasheet

acCmdInsertTableColumn

acCmdInsertUnboundSection

acCmdInvokeBuilder

acCmdJoinProperties

acCmdLastPosition

acCmdLayoutPreview

acCmdLineUpIcons

acCmdLinkedTableManager

acCmdLinkTables

acCmdListConstants

acCmdLoadFromQuery

acCmdMacroConditions

acCmdMacroNames

acCmdMakeMDEFile

acCmdMaximiumRecords

acCmdMicrosoftAccessHelpTopics

acCmdMicrosoftOnTheWeb

acCmdMicrosoftScriptEditor

acCmdMoreWindows

acCmdNewDatabase

acCmdNewGroup

acCmdNewObjectAutoForm

acCmdNewObjectAutoReport

acCmdNewObjectClassModule

acCmdNewObjectDataAccessPage

acCmdNewObjectDiagram

acCmdNewObjectForm

acCmdNewObjectFunction

acCmdNewObjectMacro

acCmdNewObjectModule

acCmdNewObjectQuery

acCmdNewObjectReport

acCmdNewObjectStoredProcedure

acCmdNewObjectTable

acCmdNewObjectView

acCmdObjBrwFindWholeWordOnly

acCmdObjBrwGroupMembers

acCmdObjBrwHelp

acCmdObjBrwShowHiddenMembers

acCmdObjBrwViewDefinition

acCmdObjectBrowser

acCmdOfficeClipboard

acCmdOLEDDELinks

acCmdOLEObjectConvert

acCmdOLEObjectDefaultVerb

acCmdOpenDatabase

acCmdOpenHyperlink

acCmdOpenNewHyperlink

acCmdOpenSearchPage

acCmdOpenStartPage

acCmdOpenTable

acCmdOpenURL

acCmdOptions

acCmdOutdent

acCmdOutputToExcel

acCmdOutputToRTF

acCmdOutputToText

acCmdPageHdrFtr

acCmdPageNumber

acCmdPageProperties

acCmdPageSetup

acCmdParameterInfo

acCmdPartialReplicaWizard

acCmdPaste

acCmdPasteAppend

acCmdPasteAsHyperlink

acCmdPasteSpecial

acCmdPivotAutoAverage

acCmdPivotAutoCount

acCmdPivotAutoFilter

acCmdPivotAutoMax

acCmdPivotAutoMin

acCmdPivotAutoStdDev

acCmdPivotAutoStdDevP

acCmdPivotAutoSum

acCmdPivotAutoVar

acCmdPivotAutoVarP

acCmdPivotChartByRowByColumn

acCmdPivotChartDrillInto

acCmdPivotChartDrillOut

acCmdPivotChartMultiplePlots

acCmdPivotChartMultiplePlotsUnifiedScale

acCmdPivotChartShowLegend

acCmdPivotChartType

acCmdPivotChartUndo

acCmdPivotChartView

acCmdPivotCollapse

acCmdPivotDelete

acCmdPivotDropAreas

acCmdPivotExpand

acCmdPivotRefresh

acCmdPivotShowAll

acCmdPivotShowBottom1

acCmdPivotShowBottom10

acCmdPivotShowBottom10Percent

acCmdPivotShowBottom1Percent

acCmdPivotShowBottom2

acCmdPivotShowBottom25

acCmdPivotShowBottom25Percent

acCmdPivotShowBottom2Percent

acCmdPivotShowBottom5

acCmdPivotShowBottom5Percent

acCmdPivotShowBottomOther

acCmdPivotShowTop1

acCmdPivotShowTop10

acCmdPivotShowTop10Percent

acCmdPivotShowTop1Percent

acCmdPivotShowTop2

acCmdPivotShowTop25

acCmdPivotShowTop25Percent

acCmdPivotShowTop2Percent

acCmdPivotShowTop5

acCmdPivotShowTop5Percent

acCmdPivotShowTopOther

acCmdPivotTableClearCustomOrdering

acCmdPivotTableCreateCalcField

acCmdPivotTableCreateCalcTotal

acCmdPivotTableDemote

acCmdPivotTableExpandIndicators

acCmdPivotTableExportToExcel

acCmdPivotTableFilterBySelection

acCmdPivotTableGroupItems

acCmdPivotTableHideDetails

acCmdPivotTableMoveToColumnArea

acCmdPivotTableMoveToDetailArea

acCmdPivotTableMoveToFilterArea

acCmdPivotTableMoveToRowArea

acCmdPivotTablePercentColumnTotal

acCmdPivotTablePercentGrandTotal

acCmdPivotTablePercentParentColumnItem

acCmdPivotTablePercentParentRowItem

acCmdPivotTablePercentRowTotal

acCmdPivotTablePromote

acCmdPivotTableRemove

acCmdPivotTableShowAsNormal

acCmdPivotTableShowDetails

acCmdPivotTableSubtotal

acCmdPivotTableUngroupItems

acCmdPivotTableView

acCmdPreviewEightPages

acCmdPreviewFourPages

acCmdPreviewOnePage

acCmdPreviewTwelvePages

acCmdPreviewTwoPages

acCmdPrimaryKey

acCmdPrint

acCmdPrintPreview

acCmdPrintRelationships

acCmdProcedureDefinition

acCmdPromote

acCmdProperties

acCmdPublish

acCmdPublishDefaults

acCmdQueryAddToOutput

acCmdQueryGroupBy

acCmdQueryParameters

acCmdQueryTotals

acCmdQueryTypeAppend

acCmdQueryTypeCrosstab

acCmdQueryTypeDelete

acCmdQueryTypeMakeTable

acCmdQueryTypeSelect

acCmdQueryTypeSQLDataDefinition

acCmdQueryTypeSQLPassThrough

acCmdQueryTypeSQLUnion

acCmdQueryTypeUpdate

acCmdQuickInfo

acCmdQuickPrint

acCmdQuickWatch

acCmdRecordsGoToFirst

acCmdRecordsGoToLast

acCmdRecordsGoToNew

acCmdRecordsGoToNext

acCmdRecordsGoToPrevious

acCmdRecoverDesignMaster

acCmdRedo

acCmdReferences

acCmdRefresh

acCmdRefreshPage

acCmdRegisterActiveXControls

acCmdRelationships

acCmdRemove

acCmdRemoveFilterSort

acCmdRemoveTable

acCmdRename

acCmdRenameColumn

acCmdRenameGroup

acCmdRepairDatabase

acCmdReplace

acCmdReportHdrFtr

acCmdReset

acCmdResolveConflicts

acCmdRestore

acCmdRowHeight

acCmdRun

acCmdRunMacro

acCmdRunOpenMacro

acCmdSave

acCmdSaveAllModules

acCmdSaveAllRecords

acCmdSaveAs

acCmdSaveAsASP

acCmdSaveAsDataAccessPage

acCmdSaveAsHTML

acCmdSaveAsIDC

acCmdSaveAsQuery

acCmdSaveAsReport

acCmdSaveLayout

acCmdSaveModuleAsText

acCmdSaveRecord

acCmdSelectAll

acCmdSelectAllRecords

acCmdSelectDataAccessPage

acCmdSelectForm

acCmdSelectRecord

acCmdSelectReport

acCmdSend

acCmdSendToBack

acCmdServerFilterByForm

acCmdServerProperties

acCmdSetControlDefaults

acCmdSetDatabasePassword

acCmdSetNextStatement

acCmdShowAllRelationships

acCmdShowDirectRelationships

acCmdShowEnvelope

acCmdShowMembers

acCmdShowNextStatement

acCmdShowOnlyWebToolbar

acCmdShowTable

acCmdSingleStep

acCmdSizeToFit

acCmdSizeToFitForm

acCmdSizeToGrid

acCmdSizeToNarrowest

acCmdSizeToWidest

acCmdSnapToGrid

acCmdSortAscending

acCmdSortDescending

acCmdSortingAndGrouping

acCmdSpeech

acCmdSpelling

acCmdSQLView

acCmdStartupProperties

acCmdStepInto

acCmdStepOut

acCmdStepOver

acCmdStepToCursor

acCmdStopLoadingPage

acCmdSubdatasheetCollapseAll

acCmdSubdatasheetExpandAll

acCmdSubdatasheetRemove

acCmdSubformDatasheet

acCmdSubformDatasheetView

acCmdSubformFormView

acCmdSubformInNewWindow

acCmdSubformPivotChartView

acCmdSubformPivotTableView

acCmdSwitchboardManager

acCmdSynchronizeNow

acCmdTabControlPageOrder

acCmdTableAddTable

acCmdTableCustomView

acCmdTableNames

acCmdTabOrder

acCmdTestValidationRules

acCmdTileHorizontally

acCmdTileVertically

acCmdToggleBreakpoint

acCmdToggleFilter

acCmdToolbarControlProperties

acCmdToolbarsCustomize

acCmdTransferSQLDatabase

acCmdTransparentBackground

acCmdTransparentBorder

acCmdUndo

acCmdUndoAllRecords

acCmdUnfreezeAllColumns

acCmdUngroupControls

acCmdUnhideColumns

acCmdUpsizingWizard

acCmdUserAndGroupAccounts

acCmdUserAndGroupPermissions

acCmdUserLevelSecurityWizard

acCmdVerticalSpacingDecrease

acCmdVerticalSpacingIncrease

acCmdVerticalSpacingMakeEqual

acCmdViewCode

acCmdViewDataAccessPages

acCmdViewDetails

acCmdViewDiagrams

acCmdViewFieldList

acCmdViewForms

acCmdViewFunctions

acCmdViewGrid

acCmdViewLargeIcons

acCmdViewList

acCmdViewMacros

acCmdViewModules

acCmdViewQueries

acCmdViewReports

acCmdViewRuler

acCmdViewShowPaneDiagram

acCmdViewShowPaneGrid

acCmdViewShowPaneSQL

acCmdViewSmallIcons

acCmdViewStoredProcedures

acCmdViewTableColumnNames

acCmdViewTableColumnProperties

acCmdViewTableKeys

acCmdViewTableNameOnly

acCmdViewTables

acCmdViewTableUserView

acCmdViewToolbox

acCmdViewVerifySQL

acCmdViewViews

acCmdVisualBasicEditor

acCmdWebPagePreview

acCmdWebPageProperties

acCmdWebTheme

acCmdWindowArrangeIcons

acCmdWindowCascade

acCmdWindowHide

acCmdWindowSplit

acCmdWindowUnhide

acCmdWordMailMerge

acCmdWorkgroupAdministrator

acCmdZoom10

acCmdZoom100

acCmdZoom1000

acCmdZoom150

acCmdZoom200

acCmdZoom25

acCmdZoom50

acCmdZoom500

acCmdZoom75

acCmdZoomBox

acCmdZoomSelection

说明

Microsoft Access 中的每个菜单命令和工具栏命令都有一个相关的常量,在 Visual Basic 中,可以将常量与 RunCommand 方法结合使用来执行该常量对应的命令。

不能使用 RunCommand 方法执行自定义菜单或工具栏上的命令,该方法只能用于内置菜单和工具栏。

RunCommand 方法可替换 DoCmd 对象的 DoMenuItem 方法。

示例

下面的示例使用 RunCommand 方法打开“选项”对话框(“工具”菜单)。

Public Function OpenOptionsDialog() As Boolean

On Error GoTo Error_OpenOptionsDialog

    DoCmd.RunCommand acCmdOptions

    OpenOptionsDialog = True

Exit_OpenOptionsDialog:

    Exit Function

Error_OpenOptionsDialog:

    MsgBox Err & ": " & Err.Description

    OpenOptionsDialog = False

    Resume Exit_OpenOptionsDialog

End Function