Results 1 to 2 of 2
Thread: Executing a Subroutine (A97 SR2)
2002-07-31, 12:24 #1
- Join Date
- Dec 2000
- Massachusetts, USA
- Thanked 0 Times in 0 Posts
Executing a Subroutine (A97 SR2)
I have created a Module with a Public Subroutine, but the only way I can find to run this is from the Design mode selecting Run.
Is there a way to run this from a Macro or DoCmd? I would like it to be run from a menu selection.
Also I would like to display a counter to the screen as the program runs (it cycles through records and I handle each individually and will increase the count after each record), but I'm not sure how to display this counter.
2002-07-31, 12:48 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: Executing a Subroutine (A97 SR2)
(1) To execute code from a macro, it must be a function, not a procedure. In Design mode of the macro, select the RunCode action and enter the function name followed by parentheses, e.g. MyFunc()
(2) To execute code from a custom toolbar button or menu item, it must also be a function. In customize mode, right click the button or menu item, and enter one of the following in the OnAction box: either
(3) You can call a subroutine from the code behind a form or report in two ways: either
For instance, you can put a command button cmdMyButton on a form, and create an OnClick event handler that executes the subroutine:
Private Sub cmdMyButton_Click()