Command buttons provide you with a way of performing action(s) by simply clicking them. When you choose the button, it not only carries out the appropriate action, it also looks as if it's being pushed in and released.
What are command buttons?
You use a command button on a form or data access page (data access page: A Web page, published from Access, that has a connection to a database. In a data access page, you can view, add to, edit, and manipulate the data stored in the database. A page can also include data from other sources, such as Excel.) to start an action or a set of actions. For example, you can create a command button that opens another form. To make a command button do something on a form, you write a macro (macro: An action or set of actions that you can use to automate tasks.) or event procedure (event procedure: A procedure that is automatically executed in response to an event initiated by the user or program code, or that is triggered by the system.) and attach it to the button's OnClick property. On a data access page, you can attach code written in either Microsoft JScript or Microsoft Visual Basic Scripting Edition (VBScript) (Visual Basic Scripting Edition (VBScript): A subset of the Microsoft Visual Basic programming system. At least Microsoft Internet Explorer 3, along with the other Web browsers, can read VBScript programs that are embedded in HTML pages.) to a command button by using the Microsoft Script Editor (Microsoft Script Editor: Used to add text, edit HTML tags, and edit any Microsoft Visual Basic Scripting Edition (VBScript) code in a data access page. You can also view your page in the Script Editor as it would appear in a Web browser.).
You can display text or a picture on a command button in a form; you can display only text on a command button in a data access page.
Creating command buttons
You can create a command button on your own, or you can have Microsoft Access create your command button for you by using a wizard. A wizard speeds up the process of creating a command button because it does all the basic work for you. When you use a wizard, Access prompts you for information and then creates the command button based on your answers.
By using the wizard, you can create more than 30 different types of command buttons. You can create command buttons to:
- Dial a phone number.
- Run a query or macro.
- Run or quit an application.
- Edit or apply a filter.
- Print or mail a report.
- Print the current record.
- Update form data.
- Find a specific record.
It's also a good idea to use the Command Button Wizard if you want to learn how to write event procedures. When Access creates a command button in a form or report with a wizard, it creates an event procedure and attaches it to the button. You can open the event procedure to see how it works and modify it to fit your needs. When you create a command button on a data access page with a wizard, Access doesn't create event procedures for you.
Wizards are not available on a stand-alone data access page or when you point a data access page to a database other than the one currently open. The Command Button Wizard is also not available if a data access page isn't bound to a table or query. You will have to create a command button on your own if wizards aren't available.
If the wizard doesn't start
This could be due to the fact that Access is running in sandbox mode but Microsoft Jet 4.0 SP8 or later is not installed on your computer. Jet 4.0 SP8 or later is required for Access to be fully functional when sandbox mode is enabled.
For more information about installing the Jet upgrade, see the Office Online article About Microsoft Jet 4.0 SP8 or later.
For more information about sandbox mode, see the Office Online article About Microsoft Jet Expression Service sandbox mode.