Code Examples

All of the code examples here are to demonstrate the use of particular RunCommand Constants. They may not be the best or the most efficient method of achieving the end result. In fact for some you should be able to find better ways. Some examples have a SendKeys Information symbol. This indicates that the code uses SendKeys which is not a robust method.

I have tried to test all the code examples and include error trapping where approrpiate. If you find any mistakes or can suggest any improvements to the examples please let me know. I would also be pleased to include any examples that you may have that use RunCommand constants that I have not already got covered.

Some of the code on this site appears by permission of the person who first wrote it. Please feel free to use the code but observe the copyright notice in the examples. Other examples are from Microsoft sources. The exact source of each piece of code is displayed above the code concerned. The RunCommand constant is highlighted within the code.

Select the sixth letter of the acCmdConstant
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Code examples starting acCmdS

The constants are colour coded dependent on the version in which they first appeared - Access 97, Access 2000, Access XP, Access 2003 or Access 2007.

Constant Used
Example
acCmdSave
Add/Remove Report Header and Footer
Add Or Remove Form Headers
Save Relationships Layout
acCmdSaveAs
Display Save As Choice
acCmdSaveAsQuery
Create a Query
acCmdSaveRecord
Save Record
acCmdSelectAll
Check Name
acCmdSelectAllRecords
Select All Records
acCmdSelectForm
Change Tab Order
acCmdSelectrecord
Copy To New Record
Delete A Record
acCmdSendToBack
Design Toolbar Extra
acCmdServerFilterByForm
Set the ServerFilterByForm Property
acCmdSetControlDefaults
Set Control Defaults
acCmdSetdatabasePassword
Set Database Password
acCmdSizeToFit
Best Fit
acCmdSizeToFitForm
Add Or Remove Form Headers
acCmdSizeToGrid
Using Short Keys
acCmdSizeToNarrowest
Using Short Keys
acCmdSizeToWidest
Using Short Keys
acCmdSortAscending
Sort A Field In Ascending Order
acCmdSortdescending
Sort A Field In Descending Order
acCmdSortingAndGrouping
Show/Hide Design Tools
acCmdSpelling
Spell Checking in Runtime Environment
acCmdSQLView
Show Query SQL
acCmdSubformDatasheet
Change Subform View
acCmdSubformDatasheetView
Change View of a Subform
acCmdSubformFormView
Change View of a Subform