Run an Access Macro or VBA Procedure from a Control Panel Form
Question details
The user wants to run an Access macro or VBA procedure from a control panel form.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A control panel or switchboard form should run an action when a user clicks a button.
- Observed behavior
- Procedures in VBA modules do not appear in the list of selectable Access macros because they are different object types.
Identify whether the action is saved as an Access macro or as a VBA procedure in a standard module. Open the control panel form in Design View and confirm that you can edit the button's On Click property.
Assign a saved Access macro to the form button
Use this method when the action is already an Access macro or when you want to create one for the button.
In the Navigation Pane, find the saved macro. If you need a new one, select Create > Macro, add the required actions, and save it with a descriptive name.
Right-click the control panel form in the Navigation Pane and select Design View. Select the button, then open its Property Sheet and select the Event tab.
In the button's On Click property, select the saved macro from the drop-down list or enter its name where supported. Save the form.
Switch to Form View and click the button to verify that the macro runs.

Call a VBA procedure from the button's On Click event
Use this method when the action is a procedure in a standard VBA module rather than a saved Access macro.
Use WPS Office for Everyday Documents and Spreadsheets
WPS Office is a free, lightweight alternative with a familiar interface for working with Office files and moving everyday document workflows. It does not run Access databases or replace Access form macros and VBA procedures.

Frequently Asked Questions
Why doesn't my VBA procedure appear in the macro list?
Access macros and VBA procedures are different object types. A procedure in a standard module must be called by name, such as from the form button's On Click event procedure.
How do I run an existing macro from button code?
In the button's On Click event procedure, use DoCmd.RunMacro "MacroName" and replace MacroName with the saved Access macro's name.
Where can I find a form button's On Click property?
Open the form in Design View, select the button, and open the Property Sheet. The On Click property is on the Event tab.
Why might a button action not run when I test it?
Check that the On Click property points to the correct macro or event procedure and that the macro or procedure name is correct. If Access shows a security warning, enable content only if you trust the database.




