You use a command button on a form or data access page 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 or event procedure 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) to a command button by using the Microsoft Script Editor.
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.
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 in 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.