Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

RunCommand Method


This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.  

The RunCommand method runs a built-in menu or toolbar command.

expression.RunCommand(Command)

expression   Required. An expression that returns one of the objects in the Applies To list.

AcCommand can be one of these AcCommand constants.
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

Remarks

Each menu and toolbar command in Microsoft Access has an associated constant that you can use with the RunCommand method to run that command from Visual Basic.

You can't use the RunCommand method to run a command on a custom menu or toolbar. You can only use it with built-in menus and toolbars.

The RunCommand method replaces the DoMenuItem method of the DoCmd object.

Example

The following example uses the RunCommand method to open the Options dialog box (Tools menu).

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
Show:
© 2014 Microsoft