Unable To Use RunCommand

There appear to be a number of RunCommand constants that cannot be used from code. For example Error 2046 seems to come up a lot. It gives a somewhat misleading message.

The following are RunCommand constants that I cannot get to work from code. The list only includes constants for which I have made several attempts to get some working code. This has normally involved trying to get it to work from events on a form or report and also adding to menus or toolbars.

For some of the constants I have either found some work around or pointed to how it may be solved.

This page is still being developed and if you know of any code or work arounds for these constants then please let me know.

Constant
Comments
acCmdNewDatabase
This can not be used either from code or as a macro action. If you want to create a file from code have a look at the CreateDatabase method of the DBEngine in Help.
acCmdOpenDatabase
This can not be used either from code or as a macro action. Michael Kaplan has a utility called TSI SOON (Shut One, Open New) database add-in which allows you to open another database.
acCmdReferences

The References option is not available when you are running code. It is only available in design time. There is a work around, you use a macro!!! However you cannot call the macro from code, it has to run from a button event or possibly a menu item.

The following are the macro actions required to display the References dialog. Replace mdlMenu with the name of one of your own modules. The Echo argument is just to stop the user seeing the open module.

ActionArgumentValue
EchoEcho On:No
OpenModuleModule Name:mdlMenu
RunCommandCommand:acCmdReferences
CloseObject Type:Module
 Object Name:mdlMenu

Note: This option can not be used with the Runtime version of Access, even if you use a macro. Thanks to Paolo for this information.

© 1998 - 2011 Terry Wickenden TKW Design Site developed, maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.