Run an Access menu or toolbar command.
Syntax expression .RunCommand(Command) Key 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.
Example function that launches the Tools | Options dialog box:
Function OpenOptionsDialog() As Boolean On Error GoTo Error_OpenOptionsDialog DoCmd.RunCommand Options OpenOptionsDialog = True
Exit_OpenOptionsDialog: Exit Function
Error_OpenOptionsDialog: 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
AccessRunCommand.com - List of all the Access run commands
© Copyright SS64.com 1999-2013
Some rights reserved