Run an Access menu or toolbar command.

      expression .RunCommand(Command)

   expression  A variable that represents a built-in command.

The RunCommand method runs the specified menu command. If the menu brings up a dialog box, the dialog box appears.
In many cases a DoCmd method will offer better automation with no user input required e.g. RunCommand acCmdPrint vs DoCmd.PrintOut acSelection

Newer versions of Microsoft Access support a larger set of RunCommand constants corresponding to new Access features.

RunCommand replaces the DoCmd.DoMenuItem method from Access 2.0, DoMenuItem is still provided for backwards compatibility only.


Application.RunCommand CmdUndo

RunCommand acCmdSaveRecord

RunCommand acCmdSelectRecord

RunCommand acCmdPrint

Example function that launches the Tools | Options dialog box:

Function OpenOptionsDialog() As Boolean
   On Error GoTo Error_OpenOptionsDialog
   DoCmd.RunCommand Options
   OpenOptionsDialog = True
   Exit Function
  MsgBox Err & ": " & Err.Description
  OpenOptionsDialog = False
  Resume Exit_OpenOptionsDialog
End Function

“You learn to speak by speaking, to study by studying, to run by running, to work by working; in just the same way, you learn to love by loving” ~ Anatole France

Related: - List of all the Access run commands

© Copyright 1999-2013
Some rights reserved