Running a module from a Form

uk

Board Regular
Joined
Nov 4, 2003
Messages
101
ok ok!!

I have created a Module, and I have created a Form.

I want to RUN the module by clicking a button on the FORM, how do I do this?

Help, Thanks!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hey uk

I'm assuming that you wish to run a macro, not a module. If so then do this...

1) RightClick the button and select "View Code". A CommandButton<Number>_Click event will be added to the forms code window.
2) Add the name of the macro into the event.
3) Run the form and click the button. The macro will run.

An event is a sub routine that responds to a user action like clicking a button or pressing a keyboard key etc, or a system action like a change of data in a sheet or the updating of a value in a control.

I Hope that helps.

anvil19
:eek:
 
Upvote 0
Me again

A module is just a container for your macros that are not events routines (which are related to a form or sheet in Excels' case) and are also available to the entire project. If you wish to run all the macros in a module you would spacify each by name.

anvil19
:eek:
 
Upvote 0
Shouldn't you substitute the word 'Function' for 'Macro'?
Modification of Anvil19's post.

In Access2K - right click the button (Form View is fine) - select Properties
Go to the Event Tab
Click into the Row labeled 'On Click' and hit the three dots off to the right

To call specific Functions in the module you wrote:

Call functionname()

Add arguments within the () if needed for the function.
Identical Syntax for Subroutines

Mike
 
Upvote 0
How would you add a Message box to show once the Module/Macro has finished?
 
Upvote 0
At the end of the last macro to run, simply add the line:

MsgBox "The macros are finished running!"
 
Upvote 0

Forum statistics

Threads
1,221,631
Messages
6,160,945
Members
451,679
Latest member
BlueH1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top