Run Access Macro using RunCode

This Access tutorial explain how to run Access Macro using RunCode.

You may also want to read:

Run Excel Macro from Access VBA

Run Access Macro

Assume that you have already written a Sub Procedure helloWorld(). To run the Macro, you can press ALT+F11 and run the Procedure by pressing F5.

Run Access Macro using RunCode 01

 

Alternatively, go back to the Access Windows, double click on the Module on the left hand side and run the Procedure by pressing F5.

Run Access Macro using RunCode 02

If you are writing a Macro for users, they probably have no idea how to run it. Instead, we should create a button for them to double click to run the Macro.

Run Access Macro using RunCode

Press ALT+F11 to go back to VBE

Create a Function that calls the Macro helloWorld. We will explain why we need to do this step.

Run Access Macro using RunCode 03

 

Go back to Access Windows, click on CREATE tab > Macro

Run Access Macro using RunCode 04

 

Select Action RunCode, and then type the Function we want to call runHello(). You must include the brackets in the suffix.

Run Access Macro using RunCode 05

Note that RunCode can only run Function, but not run Sub Procedure. On the other hand, there is no action to run Sub Procedure directly, thats why we have to create a Function and call the Sub Procedure.

 

Now you can double click on the Macro on the left hand side to run.

Run Access Macro using RunCode 06

Outbound References

https://support.office.com/en-ca/article/RunCode-Macro-Action-e6a62d3f-02c6-4daf-a5f7-402fd600bed4

Leave a Reply

Your email address will not be published.