Microsoft Access can create your command button (command button: A control that runs a macro, calls a Visual Basic function, or runs an event procedure. A command button is sometimes called a push button in other programs.) for you if you use a wizard.
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.
Also, 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 that is currently open. The Command Button Wizard is also not available if the 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.
Create or modify a command button with a wizard
Create or modify a command button without a wizard
- Open a form or a data access page in Design view (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.).
- Make sure the Control Wizards tool in the toolbox is not pressed in. This turns off the wizard.
- In the toolbox, click the Command Button tool .
- On the form or data access page, click where you want to place the command button.
- Make sure that the command button is selected, and then click Properties on the toolbar to open the command button's property sheet (property sheet: A pane that is used to view or modify the properties of various objects such as tables, queries, fields, forms, reports, data access pages, and controls.).
- Do one of the following:
To display text on a command button on a data access page: Type the text in command button's Value property box.
To display text on a command button on a form: Type the text in the command button's Caption property box.
To display a picture on a command button on a form: In the command button's Picture property box, type the path and file name for a .bmp, .ico, or .dib file. If you're not sure of the path or file name, click the Build button to open the Picture Builder.
On a form, to Create or modify a command button that runs a macro, drag the macro from the Database window to form Design view.
Create a Cancel button
- Open a form in Design view (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.).
- Click the command button, and then click Properties on the toolbar to open the command button's property sheet.
- In the Cancel property box, click Yes.
When a command button's Cancel property is set to Yes and the form is the active form, you can choose the command button by clicking it, pressing the ESC key, or pressing ENTER when the command button has the focus (focus: The ability to receive user input through mouse or keyboard actions or the SetFocus method. Focus can be set by the user or by the application. The object that has focus is usually indicated by a highlighted caption or title bar.). When the Cancel property is set to Yes for one command button, it's automatically set to No for all other command buttons on the form. Only one button can be the default on a form.
To have a Cancel button cancel all the actions that have taken place in a form or dialog box, you need to 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 OnClick property of the button.
For a form that allows irreversible operations, such as deletions, it's a good idea to make the Cancel button the default command button. To do this, set both the Cancel property and the Default property to Yes.
See an event procedure created by the Command Button Wizard